This tip is a give away. Everyone knows this, but for those who doesn’t or forgot… here’s refresher…
Here’s a typical output of a file listing using `ls -l` on a directory:
[root@unix-box icons]# ls -l | more
total 636
-rw-r–r– 1 elizar root 246 Aug 26 2005 a.gif
-rw-r–r– 1 elizar root 242 Aug 26 2005 alert.black.gif
-rw-r–r– 1 elizar root 279 Aug 26 2005 alert.black.png
-rw-r–r– 1 elizar root 247 Aug 26 2005 alert.red.gif
-rw-r–r– 1 elizar root 298 Aug 26 2005 alert.red.png
-rw-r–r– 1 elizar root 2326 Aug 26 2005 apache_pb.gif
-rw-r–r– 1 elizar root 1385 Aug 26 2005 apache_pb.png
-rw-r–r– 1 elizar root 293 Aug 26 2005 a.png
When using the -l (dash ‘el’) option of ls, the output will display a more detailed listing of the files. Here you’ll see the file properties/permission (-rw-r–r–) the number of links, the owner of the file, the group of the user, file size, the date/time stamp and finally the file name. That’s 7 column.
Changing The Time Stamp Of A File
To change the time stamp of a file (the 6th column in the `ls -l` listing), we use the UNIX command touch.
From the Man Pag:
NAME
touch – change file timestampsSYNOPSIS
touch [OPTION]… FILE…
touch [-acm] MMDDhhmm[YY] FILE… (obsolescent)
There are many options for the touch command, but the one I use fairly often is the -t option
-t STAMP; use [[CC]YY]MMDDhhmm[.ss]
Example:
[root@unix-box icons]# touch -t 200607161201 a.gif
[root@unix-box icons]# ls -l | more
total 636
-rw-r–r– 1 elizar root 246 Jul 16 2006 a.gif
-rw-r–r– 1 elizar root 242 Aug 26 2005 alert.black.gif
Other options that you may find useful are -a (change access time only) -m (modification time only) and others. Consult the man page for more details
Cheers!