Search code examples
linuxpuppetfile-permissionschmod

Change file permission for multiple file paths in a file


I have a file which stores multiple file paths in the file content, as such:

$ cat /var/tmp/sample
/etc/ssl/example/ssl-test1.cert
/etc/ssl/example/ssl-test2.cert
/etc/ssl/example/ssl-test3.cert
...

Is there a single line command to loop the file paths in the file and set the permission for each of the file paths chmod 644 <file paths in /var/tmp/sample>?


Solution

  • Another way to use xargs:

    cat /var/tmp/sample | xargs -d '\n' chmod 644