![]() |
List of directories in a file
Hi,
I have generated a list of directories that I would like to use ls and grep on, but it is not working. I am using the command Code:
cat directories.dat | xargs lsCode:
ls: cannot access ./foo/bar/baz/grault/*: No such file or directoryCheers, H. |
Check the contents of directories.dat
What is the working directory of the command ? |
The contents of the file and the working directory are fine. Just to clarify, if I run my xargs piped command I get
Code:
ls: cannot access ./foo/bar/baz/grault/*: No such file or directoryCode:
ls ./foo/bar/baz/grault/*(edit) I created the file using gawk. Could this have added some invisible delimiters or something that ls is choking on? |
Okay, I think I've figured out what it's doing.
xargs is returning the arguments with double quotes around them, and ls doesn't like that. How do I stop this from happening? |
A couple of thoughts.
Why not use a loop instead of xargs? The xargs has some limitations that you won't experience using a loop. For example: Code:
cat directories.dat | while read Dir; do ls "$Dir"; doneinterpreted and possibly expanded into a set of files. If you have space characters, tabs, slashes, back-slashes, question marks or ampersands in any of the paths they will also be interpreted. |
Getting rid of the * fixed the problem. Thanks.
|
Mark the thread as solved.
|
| All times are GMT -5. The time now is 04:31 AM. |