What I'm trying to do here is allow users to enter multiple arguments (filenames) and send them to a recycle bin I have created the sh script is called "sh safe_rm"
so I would do this:
$] sh safe_rm testFile2 testFile 3
I need both files able to be passed, any ideas?
file=$1
if [ $# -eq 0 ]
then
echo "You have not entered a file"
exit
elif [ -d $file ]
then
echo "Your file is a directory"
exit
elif [ -e $file ]
then
sendToBin
else
echo "Your file $file does not exist"
exit
fi
Try something like this:
sh safe_rm testFile2 testFile 3
for var in "$@"
do
echo "$var"
done
This will print:
testFile2
testFile
3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.