Is it possible to create a script to save and restore permissions?

前端 未结 13 1360
逝去的感伤
逝去的感伤 2021-01-30 04:29

I am using a linux system and need to experiment with some permissions on a set of nested files and directories. I wonder if there is not some way to save the permissions for t

13条回答
  •  滥情空心
    2021-01-30 04:55

    I found the answer from Dmytro L very cool. But, unfortunately, it's doesn't work, because it's generate entries like:

    chmod -rw-r--r-- ./.bashrc
    

    To avoid it, I use following command:

    find . -type f | xargs stat -c "%a %n" | awk '{print "chmod "$1" "$2}' > ./filesPermissions.sh
    

    Basically, it does the same, but generate octal entries like:

    chmod 644 ./.bashrc
    

    which works.

提交回复
热议问题