Creating a file in csh

alex at ucla-cs.UUCP alex at ucla-cs.UUCP
Thu Apr 18 05:44:13 AEST 1985


In article <6177 at Glacier.ARPA> reid at Glacier.ARPA (Brian Reid) writes:
>Aw, come on, folks. "touch filename" is the best way to create an empty file.
>All of these other schemes, involving echo and cat and what have you,
>require that the poor person reading the code stop and think about what is
>going on, but the "touch" program will (by definition) do nothing other than
>create it.
>-- 
>	Brian Reid	decwrl!glacier!reid
>	Stanford	reid at SU-Glacier.ARPA


Yes, but since "touch" won't truncate an existing file, and the
other methods (using "echo" or "cat") will, they have the advantage 
that they more closely approximate the behavior of "creat(2)."

In addition, because "echo" is a builtin in many shells and "touch"
isn't, using "echo" to create a file avoids the overhead of creating a
new process and is slightly more efficient.  On our 4.1bsd derivative,
"echo > foo" is twice as fast as "touch foo".  Admittedly, not a big
deal.

Alex Quilici
alex at ucla-locus
...{ihnp4, cepu, ucbvax}!ucla-locus!alex



More information about the Comp.unix mailing list