How do you run a command for each line of a file?

前端 未结 9 1530
梦谈多话
梦谈多话 2020-11-27 10:30

For example, right now I\'m using the following to change a couple of files whose Unix paths I wrote to a file:

cat file.txt | while read in; do chmod 755 \"         


        
9条回答
  •  离开以前
    2020-11-27 11:07

    Yes.

    while read in; do chmod 755 "$in"; done < file.txt
    

    This way you can avoid a cat process.

    cat is almost always bad for a purpose such as this. You can read more about Useless Use of Cat.

提交回复
热议问题