The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
file permissions ranj@chn Shell Programming and Scripting 7 06-11-2008 08:37 AM
To give the "unzip" permissions & "create" file permissions Mike1234 HP-UX 3 03-02-2008 01:34 PM
help with file permissions bbbngowc Security 3 12-21-2007 09:34 AM
file permissions mohanprabu Shell Programming and Scripting 4 05-31-2005 06:19 AM
File and Dir permissions thomas.jones UNIX for Dummies Questions & Answers 11 04-19-2002 06:35 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-12-2006
Registered User
 

Join Date: Apr 2006
Posts: 13
Stumble this Post!
File permissions

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.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-12-2006
Registered User
 

Join Date: Apr 2006
Posts: 13
Stumble this Post!
Got it

ls -l file1 | cut -c 4-6


Is there a more efficient way?
Reply With Quote
  #3 (permalink)  
Old 04-12-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,851
Stumble this Post!
Not really. You can write a short shell script and then alias the script - if by "efficient" you meant a simpler user interface.
Reply With Quote
  #4 (permalink)  
Old 04-12-2006
Registered User
 

Join Date: Apr 2006
Posts: 13
Stumble this Post!
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.
Reply With Quote
  #5 (permalink)  
Old 04-12-2006
Registered User
 

Join Date: Oct 2002
Posts: 670
Stumble this Post!
*Note the backticks I inserted.

Code:
TMP=`ls -l file1 | cut -c 4-6`
Reply With Quote
  #6 (permalink)  
Old 04-12-2006
Registered User
 

Join Date: Apr 2006
Posts: 13
Stumble this Post!
It worked thank you.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:28 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0