Is there any way that I can use the ls command to view the permissions that a group has on a file.
I know ls -l file1 will list all the permissions for file1.
Would I have to use the following command: ls -l file1
Then grep or sed the output to retrieve what permissions the group has.
Got it
ls -l file1 | cut -c 4-6
Is there a more efficient way?
Not really. You can write a short shell script and then alias the script - if by "efficient" you meant a simpler user interface.
How do I assign the results to a variable.
I have tried the following but it doesnt work
TMP= ls -l file1 | cut -c 4-6
This just seems to output the file permissions to the screen, whereas I want the result stored to TMP so that I can perform an If statement on it.
*Note the backticks I inserted.
TMP=`ls -l file1 | cut -c 4-6`