[comp.unix.questions] Can anyone show me a simpler way:

jad@hpcndnm.cnd.hp.com (John Dilley) (10/16/90)

In article <40852@eerie.acsu.Buffalo.EDU> cloos@acsu.buffalo.edu (James H. Cloos) writes:

>If anyone can show me a simpler way to do this (the simplest?) I'd be
>very appreciative:

>uncompress `du -a . | egrep .Z | awk '{print $2}' -`

	This is probably the simplest and fastest (and safest):

$ find . -type f -name '*.Z' -print | xargs uncompress

or, if you don't have many files, this will work:

$ uncompress `find . -type f -name '*.Z' -print`

Note that your original scheme would have tried to uncompress a
directory named foo.Z -- given, that's not likely and would not have
been tragic.  I'm just in the habit of writing production code ;-)


	You could have also reduced your pipeline using this:

$ uncompress `ls -R | fgrep .Z`

The most important thing, IMHO, is losing the awk -- you pay a high
overhead for not doing much with it.  Also, if you've got a system on
which egrep is faster than fgrep (ugh), don't use fgrep, as shown above.
My fgrep is actually aliased to the Boyer-Moore fast grep (a.k.a. bm).
Good luck to you in your massive uncompression ;-)

                          --      jad      --
			      John Dilley
			    Hewlett-Packard
                       Colorado Networks Division
UX-mail:      		     jad@cnd.hp.com
Phone:                       (303) 229-2787
--
This is not an official statement from Hewlett-Packard Corp., and does not
necessarily reflect the official position of HP.  The information above is
provided in good faith but completely without warranty of any kind.

cloos@acsu.buffalo.edu (James H. Cloos) (10/16/90)

If anyone can show me a simpler way to do this (the simplest?) I'd be
very appreciative:

uncompress `du -a . | egrep .Z | awk '{print $2}' -`

Thnaks.

(& for those novices herein, yes, it does work. :)

-JimC
--
James H. Cloos, Jr.		Phone:  +1 716 673-1250
cloos@acsu.buffalo.edu		Snail:  PersonalZipCode:  14048-0772, USA
rutgers!ub!cloos

cpcahil@virtech.uucp (Conor P. Cahill) (10/16/90)

In article <40852@eerie.acsu.Buffalo.EDU> cloos@acsu.buffalo.edu (James H. Cloos) writes:
>If anyone can show me a simpler way to do this (the simplest?) I'd be
>very appreciative:
>
>uncompress `du -a . | egrep .Z | awk '{print $2}' -`

find . -name "*.Z" -print | xargs uncompress


-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 

larry@focsys.uucp (Larry Williamson) (10/16/90)

In article <40852@eerie.acsu.Buffalo.EDU> James H. Cloos writes:
 > uncompress `du -a . | egrep .Z | awk '{print $2}' -`

find . -name '*.Z' -exec uncompress \{\} \;

-Larry

subbarao@bow.Princeton.EDU (Kartik Subbarao) (10/16/90)

In article <40852@eerie.acsu.Buffalo.EDU> cloos@acsu.buffalo.edu (James H. Cloos) writes:
>If anyone can show me a simpler way to do this (the simplest?) I'd be
>very appreciative:
>
>uncompress `du -a . | egrep .Z | awk '{print $2}' -`
>

This solution does not have two pipes, but I'm not sure if it's faster. Intuitively, I'd do:

find . -name \*.Z -exec uncompress "{}" \;

Hope this helps.

				-Kartik




(I need a new .signature -- any suggestions?)
subbarao@{phoenix or gauguin}.Princeton.EDU -|Internet
kartik@silvertone.Princeton.EDU (NeXT mail)       -|	
SUBBARAO@PUCC.BITNET			          - Bitnet

ronald@atcmp.nl (Ronald Pikkert) (10/17/90)

From article <40852@eerie.acsu.Buffalo.EDU>, by cloos@acsu.buffalo.edu (James H. Cloos):
> If anyone can show me a simpler way to do this (the simplest?) I'd be
> very appreciative:
> 
> uncompress `du -a . | egrep .Z | awk '{print $2}' -`

Try this:

find . -name "*.Z" -exec uncompress {} \;


-
Ronald Pikkert                 E-mail: ronald@atcmp.nl
@ AT Computing b.v.            Tel:    080 - 566880
Toernooiveld
6525 ED  Nijmegen

wangh@beasley.CS.ORST.EDU ( ) (10/17/90)

In article <40852@eerie.acsu.Buffalo.EDU> cloos@acsu.buffalo.edu (James H. Cloos) writes:
>If anyone can show me a simpler way to do this (the simplest?) I'd be
>very appreciative:
>
>uncompress `du -a . | egrep .Z | awk '{print $2}' -`
>
>Thnaks.
>
>(& for those novices herein, yes, it does work. :)
>

Easy. 

uncompressdir .


In case you don't have uncompressdir, there is another way

find . -name "*".Z -exec uncompress {} \;

>-JimC
>--
>James H. Cloos, Jr.		Phone:  +1 716 673-1250
>cloos@acsu.buffalo.edu		Snail:  PersonalZipCode:  14048-0772, USA
>rutgers!ub!cloos

wangh@ucs.orst.edu

ires@kaspar.UUCP (Bruce R. Larson) (10/17/90)

In article <40852@eerie.acsu.Buffalo.EDU>, cloos@acsu.buffalo.edu (James H. Cloos) writes:
> If anyone can show me a simpler way to do this (the simplest?) I'd be
> very appreciative:
> 
> uncompress `du -a . | egrep .Z | awk '{print $2}' -`
> 

How about this using SysV's /bin/find

  find . -name \*.Z -print -exec uncompress {} \;

or this using either GNU's or BSD's find

  find . -name \*.Z -exec uncompress {} \;

Bruce
blarson%kaspar.UUCP@cs.umb.edu
Integral Resources, Milton  MA

guy@auspex.auspex.com (Guy Harris) (10/18/90)

 >How about this using SysV's /bin/find
 >
 >  find . -name \*.Z -print -exec uncompress {} \;
 >
 >or this using either GNU's or BSD's find
 >
 >  find . -name \*.Z -exec uncompress {} \;
 >

The only difference between the two examples is the presence of the
"-print" option.  The S5 "find" version should work without the
"-print", and the BSD (and presumably GNU) version should work with it. 
(The BSD and S5 "find" are both recognizably descendants of the same
older "find".)  Put it in iff you want "find" to announce the names of
all the files that it's feeding to "uncompress".... 

ian@dms.cdc.com (Ian Hogg) (10/18/90)

In article <40852@eerie.acsu.Buffalo.EDU> cloos@acsu.buffalo.edu (James H. Cloos) writes:
>If anyone can show me a simpler way to do this (the simplest?) I'd be
>very appreciative:
>
>uncompress `du -a . | egrep .Z | awk '{print $2}' -`
>
 
 How about this:

   find . -name \*.Z -exec uncompress {} \;



-- 
   Ian Hogg	x-4484

mason@oct1.UUCP (David Mason) (10/18/90)

In article <40852@eerie.acsu.Buffalo.EDU> cloos@acsu.buffalo.edu (James H. Cloos)
writes:
>If anyone can show me a simpler way to do this (the simplest?) I'd be
>very appreciative:
>
>uncompress `du -a . | egrep .Z | awk '{print $2}' -`

How about

find . -name \*.Z -print | xargs uncompress

Saves du'ing all the files, prevents the possibility of having an argument
string that is too long, and is probably more readable.

--------------------
David               |      mason@oct1.UUCP (David Mason)
                    |      olsa99!oct1!mason@ddsw1.mcs.com

~~~~~~~     Has your C2 locked you out today?    ~~~~~~~

shore@mtxinu.COM (Melinda Shore) (10/23/90)

In article <1990Oct18.163200.2151@oct1.UUCP> mason@oct1.UUCP (David Mason) writes:
>How about
>
>find . -name \*.Z -print | xargs uncompress

Or

find . -name '*.Z' -exec uncompress {} \;

I've seen plenty of systems that don't have xargs, but I've never seen
find without an -exec option.
-- 
Melinda Shore                                 shore@mtxinu.com
mt Xinu                              ..!uunet!mtxinu.com!shore