Linux

File check before delete


6th of March 2008

Because I always forget, here's how to check if a file exists before attempting to delete it in bash:

 [ -f foobar.html ] && rm foobar.html

If you don't do it this way and the file doesn't exist you get this:

 rm: cannot remove `foobar.html': No such file or directory



Comment

Show all 1 comments
 

Commenting is currently disabled in Mobile version