Bash foreach loop

前端 未结 7 1218
别跟我提以往
别跟我提以往 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
    
    0 讨论(0)
提交回复
热议问题