Hi,
Here is the bash script code that should allow doing a
while loop over piped-in lines of text.
Code:
ls -1 "${MY_DIRECTORY}" | while read -e myLine ; do
echo "The current line is '${myLine}'" ;
# ...useful code goes here...
done
The key part is piping the output of
ls -1 to
while read -e .
Example output:
Code:
$ ls -1
bar
foo
foo bar
$ ls -1 | while read -e myLine ; do echo line is \'${myLine}\' ; done
line is 'bar'
line is 'foo'
line is 'foo bar'
-J_Tom_Moon_79