The best way to create a new file without editing or opening it is using touch command.
Eg:
touch test1.txt => This will create a new file test1.txt
Touch can also be used to update an existing file's timestamp to current time. The Date modified timestamp will indicate current time
Note that if you want to touch a file only and only if it exists, use the -c switch
Eg:
touch -c log.txt
(If the log.txt exists previously, only then the access and modification timestamps would update. If log.txt does not exists, the above command will do nothing i.e a new file will not be created)
Eg:
touch test1.txt => This will create a new file test1.txt
Touch can also be used to update an existing file's timestamp to current time. The Date modified timestamp will indicate current time
Note that if you want to touch a file only and only if it exists, use the -c switch
Eg:
touch -c log.txt
(If the log.txt exists previously, only then the access and modification timestamps would update. If log.txt does not exists, the above command will do nothing i.e a new file will not be created)
No comments:
Post a Comment