Bash foreach loop

前端 未结 7 1275
别跟我提以往
别跟我提以往 2020-12-22 20:39

I have an input (let\'s say a file). On each line there is a file name. How can I read this file and display the content for each one.

7条回答
  •  渐次进展
    2020-12-22 21:33

    Here is a while loop:

    while read filename
    do
        echo "Printing: $filename"
        cat "$filename"
    done < filenames.txt
    

提交回复
热议问题