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

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

    The logic applies to many other objectives. And how to read .sh_history of each user from /home/ filesystem? What if there are thousand of them?

    #!/bin/ksh
    last |head -10|awk '{print $1}'|
     while IFS= read -r line
     do
    su - "$line" -c 'tail .sh_history'
     done
    

    Here is the script https://github.com/imvieira/SysAdmin_DevOps_Scripts/blob/master/get_and_run.sh

提交回复
热议问题