I have a script that reads pathnames (one in each line and may contain space) from a file and feed all the pathnames to an external program such as `find'. How can I make it (the 2nd `find') work as if it was fed with "$@"? Thanks!

Right on, that's not a problem. My example doesn't put anything into a temporary file. It's taking input from "foo" which I borrowed from your example. I'm just generating $list with 'read' instead of 'cat'. You should be able to pipe the output to another script just fine, but you still might run into problems with the spaces. you may be able to get around that by using the exec switch to find:

#!/bin/bashfile=/tmp/paths.tmpIFS="\n"for i in $(cat $file); do find $i $@done

the trick is the IFS="\n", IFS states what the delimiting character is. In this case a newline is the delimiter for for-loops. Normally (and i think most of you encountered this before) a whitespace character will delimit the for-loop, so a path like /home/fredrik eriksson/ would itterate /home/fredrik and eriksson/.

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum