I have a file that contains path names to directories like this:
~/subdirectory1/subdirectory2/.../a/
~/subdirectory1/subdirectory2/.../b/
...
~/subdirectory1/subdirectory2/.../z/
Wanted steps:
- Open textfile
- Fetch a line
- Pass it to command "ls"
- Pipe output and exclude all occurrences of ending "jpg" or "JPG"
- Route result into a new textfile (e.g. "_command_output.log")
I was playing around with xargs
, but could not make it run.
Here is what I have so far: List files and exclude all "jpg" or "JPG" results.
ls ~/subdirectory1/subdirectory2/.../a/ | awk '!/(jpg|JPG)/'
I put that into a loop:
for i in $(cat ~/textfile-with-pathnames.txt) do
#do your stuff to $i here
##xargs ls;
ls ${i} | awk '!/(jpg|JPG)/'
done
Another try:
cat ~/textfile-with-pathnames.txt | while read line;
do
ls "$line" | awk '!(jpg|JPG)';
done
How can I run an argument for each line in the file and use the file content as parameter/argument?