Shell script for a moron
#1
Scooby Regular
Thread Starter
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes
on
0 Posts
Shell script for a moron
Me iz fik, me not no how to rite sheel skripts (me talking like a troll too, mr shine, him diamond! )
I would like to do the following in a script
rm -rf /Library/FolderOne
rm -rf /Library/StartupItems/FolderTwo
That's easy. The bit I'm having issues with is this:
Find if /etc/mach_init.d/ directory exists. If it does then;
rm -rf /etc/mach_init.d/FileOne
If it's not there, do nothing. The final, and other problematic step is to then ask the user if they wish to delete a specific directory (/Users/UserFolderOne/) and if they answer 'y' delete it, if they answer 'n' don't delete it.
Anyone wish to help a fik troll speeking moron and show me how to do the above?
I would like to do the following in a script
rm -rf /Library/FolderOne
rm -rf /Library/StartupItems/FolderTwo
That's easy. The bit I'm having issues with is this:
Find if /etc/mach_init.d/ directory exists. If it does then;
rm -rf /etc/mach_init.d/FileOne
If it's not there, do nothing. The final, and other problematic step is to then ask the user if they wish to delete a specific directory (/Users/UserFolderOne/) and if they answer 'y' delete it, if they answer 'n' don't delete it.
Anyone wish to help a fik troll speeking moron and show me how to do the above?
#2
What about this:
DIR=/etc/mach_init.d
if [ -d ${DIR} ]
then
rm -rf /etc/mach_init.d/FileOne
else
error_exit "Unable to find ${DIR}"
sleep 3
fi
If you want them to add input:
DIR=/etc/mach_init.d
if [ -d ${DIR} ]
then
echo "Do you wish to delete ${DIR} [Y/N] : \c"
read REPLY
REPLY=`echo $REPLY | tr "a-z" "A-Z"`
if [ ${REPLY} = "Y" ]
then
rm -rf /etc/mach_init.d/FileOne
echo
echo "Directory ${DIR} now deleted"
sleep 3
else
echo
echo "Directory ${DIR} will no be deleted"
sleep 3
fi
else
error_exit "Unable to find ${DIR}"
sleep 3
fi
This has not been tested. Just something to go on.
DIR=/etc/mach_init.d
if [ -d ${DIR} ]
then
rm -rf /etc/mach_init.d/FileOne
else
error_exit "Unable to find ${DIR}"
sleep 3
fi
If you want them to add input:
DIR=/etc/mach_init.d
if [ -d ${DIR} ]
then
echo "Do you wish to delete ${DIR} [Y/N] : \c"
read REPLY
REPLY=`echo $REPLY | tr "a-z" "A-Z"`
if [ ${REPLY} = "Y" ]
then
rm -rf /etc/mach_init.d/FileOne
echo
echo "Directory ${DIR} now deleted"
sleep 3
else
echo
echo "Directory ${DIR} will no be deleted"
sleep 3
fi
else
error_exit "Unable to find ${DIR}"
sleep 3
fi
This has not been tested. Just something to go on.
Last edited by jpor; 05 July 2006 at 10:40 PM.
Trending Topics
#8
Originally Posted by stevencotton
Duh, rm -i !!
echo "Do you wish to delete ${DIR} [Y/N] : \c"
read REPLY
REPLY=`echo $REPLY | tr "a-z" "A-Z"`
lines in the script.
#10
Originally Posted by DrEvil
Give him a break, he's an AIX admin - lost with out smitty's F6 feature!
(btw, just finished my AIX cert )
(btw, just finished my AIX cert )
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM