How can I remove file without asking user if he agrees to delete file? I am writing shell script and use rm function, but it asks "remove regular file?" and I really don't need this. Thank you.
|
feedback
|
migrated from stackoverflow.com Oct 12 '11 at 20:18
This question came from our site for professional and enthusiast programmers.
|
You might have
To see your aliases you can run | |||||||||||
feedback
|
|
Within a shell script, you would want to use | |||
|
feedback
|
|
If you have the required permissions to delete the file and you don't want to be prompted do the following : rm -f file -f = force Otherwise you will need to use : sudo rm -f file If you don't have permissions to the file. | |||||
feedback
|
|
the
conversely, if you want to not do something interactive, you can do
and that will repeat 'n' on the input stream (effectively answering no to questions) | |||
|
feedback
|
rm -f,yes | rmand so on, but this belongs to SU. – khachik Oct 12 '11 at 19:30rmdoesn't show a "remove regular file?" prompt by default. You must have it aliased torm -i, or defined as a function. I'm surprised that the alias is visible inside your script. Are you executing the script (./foo.sh) or sourcing it (. foo.shorsource foo.sh)? – Keith Thompson Oct 12 '11 at 19:56