7 March 2008 1 comment Linux
This blog post is 14 years old! Most likely, its content is outdated. Especially if it's technical.
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
- Previous:
- "Confessions of a College Callgirl" is the new "My Secret Life As A Prostitute" 2 March 2008
- Next:
- See you at PyCon 2008 11 March 2008
- Related by category:
- Linux tip: du --max-depth=1 27 September 2007 Linux
- How to create-react-app with Docker 17 November 2017 Linux
- Be very careful with your add_header in Nginx! You might make your site insecure 11 February 2018 Linux
- set -ex - The most useful bash trick of the year 31 August 2014 Linux
- Run something forever in bash until you want to stop it 13 February 2018 Linux
- Related by keyword:
- set -ex - The most useful bash trick of the year 31 August 2014
- Run something forever in bash until you want to stop it 13 February 2018
- Read in passwords with bash 25 March 2005
- A neat trick to zip a git repo with a version number 1 September 2017
- Catching a carriage return in bash 23 October 2006
rm -f foobar.html will not complain if the file doesn't exist