touch command...

Lars Kellogg-Stedman thelars at
Fri Feb 25 08:51:28 EST 2000

> 	You can 'touch' a file that doesn't exist yet, and that way it
> gets created (an empty file).

In this situation, it's marginally more efficient (in a shell scripting
environment) to let the shell create the file using i/o redirection:

  touch file


  >> file

Will both create "file" if it didn't already exist.  If the file
already existed, "touch file" will update the modification time, while
">> file" will not ("> file" is similar, but it will *truncate* the
file if it exists.  This is sometimes what you want.).

Using ">> file" is "marginally more efficient" because it doesn't
involve the fork and exec necessary to run touch.  If you've got a
shell loop that has to do this many times you'll probably notice a
difference, but otherwise you won't.

-- Lars

lars at -->
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
Subcription/unsubscription/info requests: send e-mail with
"subscribe", "unsubscribe", or "info" on the first line of the
message body to discuss-request at (Subject line is ignored).

More information about the Discuss mailing list