Bash foreach loop

前端 未结 7 1267
别跟我提以往
别跟我提以往 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:14

    If they all have the same extension (for example .jpg), you can use this:

    for picture in  *.jpg ; do
        echo "the next file is $picture"
    done
    

    (This solution also works if the filename has spaces)

提交回复
热议问题