🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1116

Re: How to do <cmd> file | hold file

#1116
From: Gordon C. Galligher
Date: Sun, 09 Sep 1990 17:38
35 lines
2255 bytes
In article <1990Sep8.054623.3822@sj.ate.slb.com> fabrice@sj.ate.slb.com writes:
>In article <1727@pbhyd.PacBell.COM> rjw@PacBell.COM (Rod Williams) writes:
>>>                          ...suppose I want to sort a file
>>>and place the result in the same file without destroying it,
>>
>>Doesn't 'sort' allow you to do this already in one easy step?
>>
>>	sort -o<file> <samefile>
>>
>>...or did I misunderstand the question?
>
>I use the following C-shell alias to get the output of a command into
>the file it applies to. The command should be of the form "<cmd line> <file>".
>
>	alias apply  \!\* \> /tmp/apply.\$\$ \; cp /tmp/apply.\$\$ \!\$

You will probably wish to add the following to your alias: \; rm /tmp/apply.\$\$
Without it, you may end up with quite a lot of files in the /tmp directory,
and depending upon the output of the command, this can begin to add up.

Before anyone writes:  "Just use 'mv'"  there is a very valid reason for using
'cp' as opposed to 'mv':  'cp' preserves the permissions on the file you are
copying to, whereas 'mv' does not (ie:  Mv makes the destination file the
same permissions as the source file, cp preserves the permissions on the
destination file).  If you do not believe me, then experiment on your own by 
setting umask, creating a couple of files and making the permissions different
and then using 'mv' and 'cp' combinations and see what happens.

		-- Gordon.
-- 
Gordon C. Galligher	9127 Potter Rd. #2E	Des. Plaines, Ill.    60016-4881
     telxon!ping%gorpong@uunet.uu.net (not tested)  (Is this even legal??)
     ...!uunet!telxon!ping!gorpong      (tested)    (And it works!)
"It seems to me, Golan, that the advance of civilization is nothing but an
 exercise in the limiting of privacy." - Janov Pelorat -- _Foundation's Edge_
Technical Details
Message-ID: <1990Sep9.173853.28850@ping.uucp>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!telxon!ping!gorpong
References: <1990Sep8.054623.3822@sj.ate.slb.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!telxon!ping!gorpong
From: gorpong@ping.uucp (Gordon C. Galligher)
Newsgroups: comp.unix.shell
Subject: Re: How to do <cmd> file | hold file
Summary: Remove temporary file when done.
Message-ID: <1990Sep9.173853.28850@ping.uucp>
Date: 9 Sep 90 17:38:53 GMT
References: <1990Sep8.054623.3822@sj.ate.slb.com>
Organization: The 23rd. Century
Lines: 35