I have a file, called file_list
, containing space-delimited strings, each of which is a file name of a file to be processed. I now wish to loop through all the file names and process them one by one. Pseudocode is
for every filename in file_list
process(filename);
end
I have come up with a rather clumsy solution, which is
filenames='cat file_list'
N
, by tr -cd ' ' <temp_list | wc -c
N
and parse by space each file name out with cut
Is there an easier/more elegant way of doing this?
The easiest way to do it is a classic trick that's been in the bourne shell for a while.
for filename in `cat file_list`; do
# Do stuff here
done