So I list out some directories, and I redirect the output to a file called "out". I do it with: find . \( -type d ! -name . -prune \)' > out I then go into "out" using my favorite editor and remove any directories I don't want to search. When I do a find `cat out` -name 'something*' I get an error on any directories with whitespace in them. When I try to place quotes around that name, it doesn't work, nor does putting a backslash in front of the space help. Any shell experts out there have any ideas? === Al
> -----Original Message----- > From: centos-bounces at centos.org [mailto:centos-bounces at centos.org] On > Behalf Of Al Sparks > Sent: Monday, March 19, 2007 3:33 PM > To: Centos List > Subject: [CentOS] Shell Question > > So I list out some directories, and I redirect the output to a file > called "out". > > I do it with: > find . \( -type d ! -name . -prune \)' > out > > I then go into "out" using my favorite editor and remove any > directories I don't want to search. > > When I do a > find `cat out` -name 'something*' > > I get an error on any directories with whitespace in them. When I try > to place quotes around that name, it doesn't work, nor does putting a > backslash in front of the space help. > > Any shell experts out there have any ideas? > === Al >Unless I am mistaken, you either have to backslash the quotes or use double backslashes to quote the spaces because the shell will strip off one backslash when the value comes out of cat, leaving the spaces unquoted for the find.
In article <20070319223304.57032.qmail at web37115.mail.mud.yahoo.com>, Al Sparks <data345 at yahoo.com> wrote:> So I list out some directories, and I redirect the output to a file > called "out". > > I do it with: > find . \( -type d ! -name . -prune \)' > out > > I then go into "out" using my favorite editor and remove any > directories I don't want to search. > > When I do a > find `cat out` -name 'something*' > > I get an error on any directories with whitespace in them. When I try > to place quotes around that name, it doesn't work, nor does putting a > backslash in front of the space help. > > Any shell experts out there have any ideas?Try replacing the second find with: cat out | while read d; do find "$d" -name 'something*'; done Cheers Tony -- Tony Mountifield Work: tony at softins.co.uk - http://www.softins.co.uk Play: tony at mountifield.org - http://tony.mountifield.org
Al Sparks wrote:> So I list out some directories, and I redirect the output to a file > called "out". > > I do it with: > find . \( -type d ! -name . -prune \)' > out > > I then go into "out" using my favorite editor and remove any > directories I don't want to search. > > When I do a > find `cat out` -name 'something*' > > I get an error on any directories with whitespace in them. When I try > to place quotes around that name, it doesn't work, nor does putting a > backslash in front of the space help. > > Any shell experts out there have any ideas? > === AlYou might be able to do something like this: IFS=$'\n' find `cat out` -name 'something*' James Pearson