精通unix shell脚本编程中关于while循环的问题!
while read LINE
do
echo "$LINE"
done < <(command)
I know this looks a bit odd. I got this trick from one of my co-workers, Brian Beers.
What we are doing here is input redirection from the bottom of the loop, after the
done loop terminator, specified by the done < notation. The < (command) notation
executes the command and points the command’s output into the bottom of the loop.
NOTE The space between<<in < <(command)is required!
我测试了一下,始终报错,如下:
#!/bin/ksh
while read line
do
echo $line
done< <(cat ./test1.sh)
test2.sh[2]: 0403-057 Syntax error at line 6 : `<' is not expected.
请帮忙举个例子,谢谢!