Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a folder with some files, which each have different permissions. Some are read-only, some are read/write, some are read/execute.

How can I copy the permissions from user to group, so that for example a file marked read-write for user will be set to read-write for group, but a file read-executable for a user will be set read-executable for the group.

Can this be done with a single command?

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

chmod from coreutils understands such assignments:

chmod g=u file
share|improve this answer
    
just a joke :) #! /bin/bash for FILE in * do chmod g=$(ls -l $FILE | cut -c 2,3,4) $FILE done –  Hojat Taheri Apr 4 '13 at 14:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.