21.7 Setting File Modification Time with touchHow can you make a file quickly (often for some kind of test)? In the Bourne shell, use the command below. Because this command uses a built-in ( 1.10 ) operator, it's fast and efficient. This creates a new file or empties an existing file:
$ The C shell doesn't allow that. From the C shell, you can empty a file by copying /dev/null onto it ( 24.1 ) . The easiest way to create an empty file is with the touch command. touch is also useful from any shell to change an existing file's modification time to "now"-without changing the file's contents (usually for an automatic file time comparison ( 17.8 , 28.13 , 21.9 ) ). You can touch more than one file at a time. Just type:
%
%
where
and:
For example, to create a file dated 4 p.m., March 20 of this year, give the command:
%
If you don't want to use a different timestamp (that is, you want the
current time) and the filename starts with a digit,
touch
might
think that the filename is a time and complain "date: bad conversion."
To start a filename with a digit, use a relative pathname that starts
with a
% Article 22.16 explains cpmod , a program on the CD-ROM for copying dates and permissions from file to file. - , |
|