View Single Post

  #1 (permalink)  
Old 02-20-2007, 03:21 PM
shankar100 shankar100 is offline
Junior Member
User
 
Join Date: Dec 2006
Location: Hyderabad,India.
Posts: 16
Rep Power: 0
shankar100
Send a message via Yahoo to shankar100
Default Shell script to delete a file with a dialog utility

Hello,

I am learning shell script by following online documentation of vivek (freeos.com). I need some help to fix the problem. please see the below script.

dialog --title "Input- Delete a file" --backtitle "Welcome to linux dialog utility" --inputbox "Enter the file name to delete" 8 60 2>/home/shankar/name
sel=$?
out=`cat /home/shankar/name`
case $sel in
0) rm $out; echo "file is deleted";;
1) echo "You pressed cancel";;
255) echo "You pressed ESC";;
esac
rm /home/shankar/name

The above script will delete the given file, what if there is no file exists ( if (! -f $out) ). The script should check for the file on the system , if finds delete that otherwise it leave a message "no such file exists". Please help me
Reply With Quote