Usage of Touch Command | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Usage of Touch Command

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-08-2005
ravi.sadani19 ravi.sadani19 is offline
Registered User
 
Join Date: Jul 2005
Last Activity: 16 June 2009, 7:12 AM EDT
Posts: 42
Thanks: 0
Thanked 0 Times in 0 Posts
Usage of Touch Command

HI all,

I am wrkin on HP Unix .. can any1 let me know da usage of Touch command in shell scripting
Sponsored Links
    #2  
Old 08-08-2005
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
 
Join Date: Apr 2004
Last Activity: 20 January 2014, 5:51 AM EST
Location: Bordeaux, France
Posts: 1,711
Thanks: 2
Thanked 61 Times in 57 Posts
From the touch man page :

Quote:
Description

The touch command updates the access and modification times of each file
specified by the File parameter of each directory specified by the Directory
parameter. If you do not specify a value for the Time variable, the touch
command uses the current time. If you specify a file that does not exist, the
touch command creates the file unless you specify the -c flag.

The return code from the touch command is the number of files for which the
times could not be successfully modified (including files that did not exist and
were not created). Note Any dates beyond and including the year 2038 are
invalid.

. . . . . . . . .

Examples

1. To update the access and modification times of a file, enter:

touch program.c

This sets the last access and modification times of the program.c file to
the current date and time. If the program.c file does not exist, the touch
command creates an empty file with that name.
2. To avoid creating a new file, enter:

touch -c program.c

3. To update only the modification time, enter:

touch -m *.o

This updates the last modification times (not the access times) of the
files that end with a .o extension in the current directory. The touch
command is often used in this way to alter the results of the make command.
4. To explicitly set the access and modification times, enter:

touch -c -t 02171425 program.c

This sets the access and modification dates to 14:25 (2:25 p.m.) February
17 of the current year.
5. To use the time stamp of another file instead of the current time, enter:

touch -r file1 program.c

This gives the program.c file the same time stamp as the file1 file.
6. To touch a file using a specified time other than the current time, enter:

touch -t 198503030303.55 program.c

This gives the program.c file a time stamp of 3:03:55 a.m. on March 3,
1985.

Jean-Pierre.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using touch command in ftp nick1982 UNIX for Dummies Questions & Answers 2 07-01-2011 10:21 AM
Command to display the space usage (memory usage) of a specific directory. abhisheksunkari UNIX for Dummies Questions & Answers 2 11-12-2010 03:26 AM
how can I find cpu usage memory usage swap usage and logical volume usage alert0919 HP-UX 3 12-02-2008 01:38 PM
touch command help wsn UNIX for Dummies Questions & Answers 6 02-11-2008 01:01 PM
touch command OrthoProof USA UNIX for Dummies Questions & Answers 3 06-08-2006 06:38 PM



All times are GMT -4. The time now is 02:15 PM.