How 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 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. 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 ). You can touch more than one file at a time. Just type:
|touch||Some versions of touch (including the GNU version on the CD-ROM) can create a file with an arbitrary timestamp. That is, you can use touch to make a file that's backdated to any point in the past (or, for that matter, postdated to some point in the future). If your version can do that, the syntax is probably like:|
date filename1 filename2
date has the form:
is two digits, representing the month.
is two digits, representing the day of the month.
is two digits, representing the hour (on a 24-hour clock).
is two digits, representing the minute within the hour.
is two digits, representing the year (within the twentieth century). These two digits are optional; if you omit them, date assumes the current year.
For example, to create a file dated 4 p.m., March 20 of this year, give the command:
touch 03201600 foo
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. For example, to make a file123456 in the current directory:
Article 22.16 explains cpmod, a program on the CD-ROM for copying dates and permissions from file to file.
|21.6 A File's Inode Change (not "Creation"!) Time||21.8 The MAILCHECK and mail Variables Check More than Mail|