tcsh, when you quote a command substitution, it is split on a one per non empty line basis, which sounds like exactly what you want here, so you can do:
find -- "`cat list.txt`" -name '*.c'
In POSIX-like shells, you'd need to do something like:
(set -o noglob; IFS='
'; find -- $(cat list.txt) -name '*.c')
to achieve the same.
list.txt contains at least one non-empty line (otherwise, depending on the
find implementation, you'll get an error message or it will look in the current directory).
That also assumes that none of the lines start with
- or are
find predicates (most of
find predicates start with
-type...), but there's also
That also assumes
list.txt is small enough to fit in the maximum size of arguments to a command.
Another alternative is to use
<list.txt sed 's/"/"\\""/g;s/.*/"&"/'|xargs tcsh -c 'find $argv:q -name "*.c"'
sed quotes each line in a format understood by
Same limitations as above except that it should work around the limitation on number of arguments by running as many
find commands as needed to avoid it, and it assumes the content of
list.txt is valid text in the current locale. Some
xargs implementations also have a rather low limit on the maximum size of any argument which can be significantly smaller than the maximum size of a path.