Untitled Document
touch Command

The touch command is use to change or set the modification and access time to predefined values .The touch command changes these times , and has following syntax

   touch options expression filename(s)  

The expression consist of an eight digit number using the format MDDhhmm (month,day,hour and minute)

1. Basic Example -

When touch used without options or expression , both times are set to current time .

   touch user.txt    

2. Creating file with touch command -

The touch command creates a file if it doesn't exists . The below command creates file sample.txt

   touch sample.txt 

3. Changing timestamp of a file

The following command changes the time stamp of file emp.csv to 3 march 05:30 Am .

   touch 03030530 emp.csv 

4. Changing modification ( -m ) and access time ( -a ) indiviually of a file

It is also possible to change the two times indivually . The -m and -a option change the modification and access times respectively .

   touch -m 02281030 emp.csv
   touch -a 01261650 emp.csv  
Untitled Document