Touch Command with examples

Touch command will create a file if the given file is not present and if it is already present will modify its modification or access time depending on argument you pass to it, but not overwrite its content.

Syntax : touch [options] file_name
$ touch -help
will show you all available option. If you do not pass any option you can create multiple file with single touch command.


Examples for your reference:
$ touch google.txt
The above command will create a file google.txt 


$ touch google.txt yahoo.txt umasarath.txt
The above command will create files yahoo and umasarath. Since google was already present, it will modify its access time.


$ touch -a google.txt
The above command will modify the access time of google file.


$ touch -m yahoo.txt
The above command will modify the modification time of yahoo file.


$ touch -am umasarath.txt
The above command will modify both access and modification time of umasarath file.


$ touch -r yahoo.txt umasarath.txt
The above command will set datetime of yahoo.txt to umasarath.txt











Comments

Popular posts from this blog

[SOLVED] - RSYNC not executing via CRON

RSYNC command without authentication - 8 simple steps

Install JDK on Ubuntu