LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-28-2010, 05:08 PM   #1
cpthk
Member
 
Registered: Aug 2009
Posts: 31

Rep: Reputation: 15
How to get file permission as digits?


I am trying to write a program that gets file permission. I understand linux has ls -l can view file permission, but it has too many information that I have to process those strings in my program. Is there an easier command just return me the permission digits like:

$ getperm /home/file
0440
$
 
Old 06-28-2010, 05:16 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Here is a couple of suggestions:
Code:
$ find /path/to/file -printf "%#m\n"
$ stat -c%a /path/to/file
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Any log file for checking file permission change history in RHEL 5.1? bilalcochin Linux - Newbie 3 04-02-2010 09:57 AM
I need help finding out last 4 digits s_b Linux - Newbie 1 10-16-2008 08:16 AM
BASH - convert single digits to double digits. rickenbacherus Programming 7 05-07-2008 06:53 AM
grep and digits gawain Linux - Software 7 02-20-2008 02:13 AM
my cd contents file names not displaying morethan 8 digits. AMajeed AIX 5 08-08-2007 09:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:32 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration