Read line by line in bash script

前端 未结 7 1913
暗喜
暗喜 2020-12-12 13:45

I want to do the following, read line by line of a file and use the value per line as params

FILE=\"cat test\"
echo \"$FILE\" | \\
while read CMD; do
echo $C         


        
7条回答
  •  不知归路
    2020-12-12 14:28

    The correct version of your script is as follows;

    FILE="cat test"
    $FILE | \
    while read CMD; do
    echo $CMD
    done
    

    However this kind of indirection --putting your command in a variable named FILE-- is unnecessary. Use one of the solutions already provided. I just wanted to point out your mistake.

提交回复
热议问题