Filemanagement

G. Matthew Rice matt-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org
Sun Mar 7 21:24:09 UTC 2004


"Peter L. Peres" <plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org> writes:
> >         find . -name '*.pgn' | xargs cat >target.file
> 
> Yes, correct, my bad. Anything that expands a couple of hundred files as
> CLI arguments will likely fail. Also that should be cat >>target.file

Why '>>'?  The shell is only opening target.file once for this entire
command.  As evidence, I offer:

  [matt-aNH4h1Gy6+c at public.gmane.org tmp]$ echo placeholder >extra.txt
  [matt-aNH4h1Gy6+c at public.gmane.org tmp]$ for i in a b c;do echo $i >$i.pgn; done
  [matt-aNH4h1Gy6+c at public.gmane.org tmp]$ find . -name '*.pgn' | xargs -n 1 cat extra.txt >out
  [matt-aNH4h1Gy6+c at public.gmane.org tmp]$ cat out
  placeholder
  a
  placeholder
  b
  placeholder
  c
  [matt-aNH4h1Gy6+c at public.gmane.org tmp]$

Besides, with '>>' some shells [depending on settings] will complain that the
file doesn't exist and exit the command with an error.  And if it does exist,
it won't truncate the file first [in all shells].

PS - I test before I post ;)
-- 
g. matthew rice <matt-s/rLXaiAEBtBDgjK7y7TUQ at public.gmane.org>                            starnix inc.
phone: 905-771-0017 x242                        thornhill, ontario, canada
http://www.starnix.com              professional linux services & products
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list