faigin@sdcrdcf.UUCP (Daniel Faigin) (04/09/85)
In article <1581@ukma.UUCP> david@ukma.UUCP (David Herron, NPR Lover) writes: > > echo -q This creates an empty file >new.file > >Since, with csh, there is no longer an easy way to create an empty >file. (With sh one could type just ">new.file"). > Actually, the easiest way to create an empty file in csh is: cat < /dev/null > newfile Daniel -- UUCP: {akgua allegra ihnp4 hplabs sdcsvax trwrb cbosgd}!sdcrdcf!faigin ARPA: sdcrdcf!faigin@UCLA-CS.ARPA W: SDC, 2500 Colorado MD 52-46; Santa Monica CA 90406; (213) 820-4111 x6493 H: 11743 Darlington Avenue #9; Los Angeles CA 90049; (213) 826-3357 It is easier to change the specification to fit the program than vice-versa. -- A. J. Perlis, SIGPLAN 17:9 Sept 1982
allyn@sdcsvax.UUCP (Allyn Fratkin) (04/10/85)
What's wrong with "touch filename" ? -- From the virtual mind of Allyn Fratkin allyn@UCSD.ARPA or UCSD EMU/Pascal Project {ucbvax, decvax, ihnp4} U.C. San Diego !sdcsvax!allyn "Generally you don't see that kind of behavior in a major appliance."
alex@ucla-cs.UUCP (04/11/85)
The simplest, most efficient way to create an empty file running under the csh (at least under 4.* BSD): echo > empty-file
toby@gargoyle.UChicago.UUCP (Toby Harness) (04/12/85)
In article <> faigin@sdcrdcf.UUCP (Daniel Faigin) writes: >>Since, with csh, there is no longer an easy way to create an empty >>file. (With sh one could type just ">new.file"). >Actually, the easiest way to create an empty file in csh is: > cat < /dev/null > newfile Try ":>new.file" Toby Harness Ogburn/Stouffer Center, University of Chicago ...ihnp4!gargoyle!toby
reid@Glacier.ARPA (Brian Reid) (04/13/85)
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@SU-Glacier.ARPA
jaap@mcvax.UUCP (Jaap Akkerhuis) (04/15/85)
In article <1899@sdcrdcf.UUCP> faigin@sdcrdcf.UUCP (Daniel Faigin) writes: > In article <1581@ukma.UUCP> david@ukma.UUCP (David Herron, NPR Lover) writes: > > > > echo -q This creates an empty file >new.file > > > >Since, with csh, there is no longer an easy way to create an empty > >file. (With sh one could type just ">new.file"). > > > > Actually, the easiest way to create an empty file in csh is: > cat < /dev/null > newfile > To contribute to this silly discussion, the most portable way to create an empty file is: touch "Empty file"
mjk@ttrdc.UUCP (Mike Kelly) (04/17/85)
aaaarrrrrgggggghhhhhh!!!! ENOUGH ALREADY!
alex@ucla-cs.UUCP (04/17/85)
In article <6177@Glacier.ARPA> reid@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@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@ucla-locus ...{ihnp4, cepu, ucbvax}!ucla-locus!alex
leiby@masscomp.UUCP (Mike Leibensperger) (04/17/85)
If you decide to create your empty files with touch(1), don't forget that if the file already exists, touch(1) will update the modify time but *won't* zero the file! If it matters... -- Rt. Rev. Mike Leibensperger, Archbishop of Chelmsford Church of St. Clint the Righteous ("Feel lucky, Pink Boy?") Masscomp; 1 Technology Park; Westford, MA 01886 {decvax,harpo,tektronix}!masscomp!leiby
jty@tut.UUCP (Jyrki Yli-Nokari) (04/19/85)
Come on, the only real way to do it is: :-> file Credit to: Jyrki Yli-Nokari ...mcvax!enea!tut!jty
lrd@drusd.UUCP (L. R. DuBroff) (04/20/85)
It has been noted by many respondents that "touch filename" will not create an empty file if filename exists. Touch(1) has another "gotcha!", at least in all UNIX(tm) systems that I have used. You may say "touch [-amc] [time_date] filename", where time_date is a numerical string that indicates the time and date to which you want to reset the access or modification (default) time of the file (-c prevents file creation if filename did not exist). Thus, "touch 12345" will NOT create an empty file named 12345, but will instead return: date: bad conversion In order to use touch to create an empty file named 12345, you need to say: "touch ./12345"
shimell@stc-a.UUCP (Dave Shimell) (04/20/85)
> > > echo -q This creates an empty file >new.file > >To contribute to this silly discussion, the most portable way >to create an empty file is: > touch "Empty file" Actually, Jaap, this does not work on IS/1 (Version 6 PWB). I presume this is also the case with other V6 systems. Best is: cat /dev/null > "Empty file". Regards, Dave Shimell. shimell@stc-a.UUCP {root44, ukc, idec, stl, creed, stc-[bcdf]}!stc-a!shimell -- Regards, Dave Shimell. shimell@stc-a.UUCP {root44, ukc, idec, stl, creed, stc-[bcdf]}!stc-a!shimell
lowry@fortune.UUCP (John Lowry) (04/21/85)
In article <6177@Glacier.ARPA> reid@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@SU-Glacier.ARPA Wrong. If the file exists, touch will not create it and it will not be empty, unless it was before. --John Lowry
david@ukma.UUCP (David Herron, NPR Lover) (04/26/85)
In article <778@sdcsvax.UUCP>, allyn@sdcsvax.UUCP (Allyn Fratkin) writes: > What's wrong with "touch filename" ? As the originator of this mess ... The problem with "touch filename" is that the file isn't gauranteed to be empty. The solution I like best came from Peter Honeyman, alias \> tee \!* \</dev/null (I think that's how it went. It was that general idea anyway) Now, don't y'all think this has gone on far enough? We've had I don't know how many postings to the net about this, not to mention hundreds of personal responses. All for a simple joke? Not even for one with lots of content. :-) -- --- David Herron --- ARPA-> ukma!david<@ANL-MCS> or david%ukma.uucp@anl-mcs.arpa --- Or even anlams!ukma!david@ucbvax.arpa --- UUCP-> {ucbvax,unmvax,boulder,oddjob}!anlams!ukma!david --- cbosgd!ukma!david "The home of poly-unsaturated thinking".
alexis@reed.UUCP (Alexis Dimitriadis) (04/30/85)
>> What's wrong with "touch filename" ? > >As the originator of this mess ... > >The problem with "touch filename" is that the file isn't gauranteed >to be empty. > >The solution I like best came from Peter Honeyman, > > alias \> tee \!* \</dev/null > >(I think that's how it went. It was that general idea anyway) > > >Now, don't y'all think this has gone on far enough? For an April fool's joke, it has certainly had enough discussion. But given the bizarre ways some folks routinely employ to create an empty file, (see above :-), I think the discussion was not without merit. To summarise: The most convenient way to create empty files in both shells is by using the shell's own output redirection facilities-- there is no need to involve other programs. For the Bourne shell, that is done simply with > file With cshell, you can use :> file (I believe the : is part of an empty label), or use echo > file (The cshell executes echo directly, the Bourne shel doesn't. And, you need not use "echo -n", the cshell echo does not append a newline when there are no arguments). Forgive me if I am redundant, forgive me if I am redundant, Alexis Dimitriadis. -- _______________________________________________ As soon as I get a regular job, the opinions expressed above will attach themselves to my employer, who will never be rid of them again. alexis @ reed ...ihnp4!{harvard|tektronix}!reed ...decvax!tektronix!reed ...teneron!reed