$ whatis touch

touch(1) - change file access and modification times


Examples:


Before I demonstrate the touch command, let's identify what is my User ID, 'UID' and Group ID, 'GID'.

$ id

uid=101(wahid) gid=10(staff) groups=10(staff)

Here I am running the command below to verify that I am logged in as 'wahid'.

$ whoami

wahid

Then, I run the command below to find out the terinal (TTY), and the date and time I have logged in.

$ who am i

wahid pts/3 2011-01-09 17:44 (:0.0)

In the next two commands I am in the 'Test' directory and create an empty file 'newfile' with the timestamp of the current date and time of the system.

$ pwd

/export/home/wahid/Public/Test

$ touch newfile

I verify that the 'newfile' was zero byte in size and has the current system timestamp as it's creating date and time.

$ ls -ld newfile

-rw-r--r-- 1 wahid staff 0 2011-01-09 17:55 newfile

Using the '-t TIMESTAMP' option of the touch command, I change the timestamp of the file to 12:00

noon of January 1st, 2011.

$ touch -t 1101011200 newfile

I verify the change as shown below:

$ ls -ld newfile

-rw-r--r-- 1 wahid staff 0 2011-01-01 12:00 newfile

Now, I run the command 'date' to show today's date and time.

$ date

Sun Jan 9 17:56:10 PST 2011

Here, I change the timestamp of the 'ne wfile' to the current date and time timestamp.

$ touch newfile

I verfiy again the change and know the touch command worked as it was expected.

$ ls -ld newfile

-rw-r--r-- 1 wahid staff 0 2011-01-09 17:56 newfile


Please click on " man touch " to see the Manual Page for this command.


Previous Home Page Next



Contact us      |      About us      |      Term of use      |       Copyright © 2000-2024 MyWebUniversity.com ™