changing chmod for files but not directories

前端 未结 5 1599
野趣味
野趣味 2020-12-22 17:14

I need to use chmod to change all files recursivly to 664. I would like to skip the folders. I was thinking of doing something like this

ls -lR | grep ^-r |          


        
5条回答
  •  执笔经年
    2020-12-22 18:10

    Another way to do this is to use find ... -exec ... as follows:

    find . -type f -exec chmod 644 {} \;
    

    The problem is that the -exec starts a chmod process for every file. The xargs approach avoids this, and is superior provided that you have a version of find and xargs that can cope with the "spaces in pathnames" problem; see the accepted answer.

    And for the record, using back-ticks is going to break if there are too many files to be chmoded, or the aggregated length of the pathnames is too large.

提交回复
热议问题