Home Messages Index
[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index

Re: Grepping a directory of files

  • Subject: Re: Grepping a directory of files
  • From: Nix <nix-razor-pit@xxxxxxxxxxxxx>
  • Date: Mon, 07 Nov 2005 11:45:56 +0000
  • Cancel-lock: sha1:672wjzVvn0+PYJWhuhrWvOVhr30=
  • Newsgroups: uk.comp.os.linux
  • Organization: the Core
  • References: <1131297397.24932.65.camel@localhost> <TO1rVIMFZmbDFwtD@dev.null.davjam.org> <dkmhav$v3a$1@godfrey.mcc.ac.uk>
  • Reply-to: Nix <$}xinix{$@esperi.org.uk>
  • User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Corporate Culture, linux)
  • Xref: news.mcc.ac.uk uk.comp.os.linux:204680
On Mon, 07 Nov 2005, Roy Schestowitz announced authoritatively:
>         # global - execute command in all subdirectories

Very nifty script, except...

> 
>         exec 3<&0               # save standard input
>         find . -type d -print | # print all directory names
>             while read dirname
>             do
>                 (cd $dirname
>                 exec 0<&3       # restore standard input

unless you actually want to pass that fd 3 to the command I'd make
that line
                  exec 0<&3 3<&-

>                 "$@"            # run command
>                 )
>             done
>         exec 3<&-               # close file descriptor

HTH :)

-- 
`Heinlein is quite competent at putting together sentences, but usually
he also puts together a plot to go with them.' --- Russ Allbery

[Date Prev][Date Next][Thread Prev][Thread Next]
Author IndexDate IndexThread Index