March 24th, 2010, 03:38 PM
How to create a blank file if that file does not exists?
I have a requirement like, I need to write a command which will check for a file and if the file does not exists in that directory then it will create a new file using touch command. If the file is already exists then it wouldn't do anything.
Is it possible to get the result using any UNIX command?
Thanks in advance.
March 24th, 2010, 05:24 PM
Hi, you should be able to do what you want with:
if [[ ! -f $file ]]; then