Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!gatech!hubcap!ncrcae!sauron!wescott From: wescott@sauron.UUCP Newsgroups: comp.unix.questions Subject: Re: Dealing with large directories Message-ID: <913@sauron.Columbia.NCR.COM> Date: Mon, 29-Jun-87 08:41:58 EDT Article-I.D.: sauron.913 Posted: Mon Jun 29 08:41:58 1987 Date-Received: Tue, 30-Jun-87 03:31:41 EDT References: <8079@brl-adm.ARPA> Reply-To: wescott@sauron.Columbia.NCR.COM (Mike Wescott) Organization: Advanced Systems Development, NCR Corp., Columbia, SC Lines: 37 In article <8079@brl-adm.ARPA> cosell@PROPHET.BBN.COM (Bernie Cosell) writes: > I'd appreciate some shell-programming techniques for dealing with large > directories ... Things like "[a-m]*/[n-z]*" in two runs only work AFTER you > get blown out of the water. Are there tricks for making this sort of thing > not be a problem? Try xargs(1). You'll find it in SysV and in mod.sources archives. xargs(1) takes a list of whatever on stdin and passes them as arguments to a program (supplied as the first arg to xargs). For example: find . -type f -print | xargs dosomething -x ends up executing dosometing -x on every file in the current working directory and all subdirectories. This is much more efficient than find . -type f -exec dosomething -x "{}" ":" Filtering the output of find through sed or grep and/or using ls to generate filenames can let you be more specific in the criteria used. Another example of xargs use: find . -type f -print | xargs file | \ grep 'text$' | sed 's/:^I//' > flist This makes a list of all files that file(1) cosiders to be "text" of one form or another. -- -Mike Wescott wescott@ncrcae.Columbia.NCR.COM