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

前端 未结 9 1552
梦谈多话
梦谈多话 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:05

    If you know you don't have any whitespace in the input:

    xargs chmod 755 < file.txt
    

    If there might be whitespace in the paths, and if you have GNU xargs:

    tr '\n' '\0' < file.txt | xargs -0 chmod 755
    

提交回复
热议问题