Sponsored Content
Top Forums Shell Programming and Scripting Command to return permissions in octal format Post 302346541 by Festus Hagen on Saturday 22nd of August 2009 09:58:22 PM
Old 08-22-2009
A quick search for octal permissions reveals your answer!

Display Permissions in Octal

-Enjoy
fh : )_~
 

10 More Discussions You Might Find Interesting

1. Programming

octal and strings

hi i have a peculiar problem...i have a number of stirngs separated by a '/0'. it looks somethings like: char test="abk\0jsdhj\01234\0" actually i will be reading this from a file or something... im supposed to change the \0 to a ',' but in C the octal representation starts with a '\'...... (1 Reply)
Discussion started by: strider
1 Replies

2. UNIX for Dummies Questions & Answers

need command to change permissions

I have a very simple question which I am not able to crack. There is an user with same username and groupname. How do I change permissions of a file to have the username and groupname assigned for the user "test". Appreciate you help. -Carl (1 Reply)
Discussion started by: calredd
1 Replies

3. UNIX for Dummies Questions & Answers

to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 's

Hi All, Can anyone please let me know the syntax / how to pick up the Return Code ( RC) from the mailx command and return it to SAS uisng 'system()' function and '${?}'. I am in a process to send the mail automatically with an attachment to bulk users. I have used 'Mailx' and 'Unencode'... (0 Replies)
Discussion started by: manas6
0 Replies

4. UNIX for Dummies Questions & Answers

Display permissions in octal format

Hi, Is there any way to display the permissions in octal format rather than "rwxrwxrwx" format. I have a file and i want to see the permissions in octal format. Please help. (11 Replies)
Discussion started by: venkatesht
11 Replies

5. Shell Programming and Scripting

[bash]printf octal instead of decimal

Hello everybody, I would like to understand why the printf function is returning me an octal value with this command : printf %4.4d 0010 returns 0008 printf %4.4d 10 returns 0010 Thanks for help. (3 Replies)
Discussion started by: dolphin06
3 Replies

6. UNIX for Dummies Questions & Answers

ls switch to view octal permissions??

Is there seriously not an easy way to do this? you really need a script for it? that is ridiculous! Please someone tell me there is an ls switch to view octal permissions instead of rwx i want 777. (1 Reply)
Discussion started by: glev2005
1 Replies

7. Shell Programming and Scripting

return a list of unique values of a column from csv format file

Hi all, I have a huge csv file with the following format of data, Num SNPs, 549997 Total SNPs,555352 Num Samples, 157 SNP, SampleID, Allele1, Allele2 A001,AB1,A,A A002,AB1,A,A A003,AB1,A,A ... ... ... I would like to write out a list of unique SNP (column 1). Could you... (3 Replies)
Discussion started by: phoeberunner
3 Replies

8. UNIX for Dummies Questions & Answers

Deleting octal values

I have some junk values in my files 鵶„‰¼±¤¡ad. am able to find the octal values as below by using od command. 303 251 265 266 204 211 274 261 244 241 141 144 i want to know how to delete the octal this values . (5 Replies)
Discussion started by: vino.paal
5 Replies

9. Shell Programming and Scripting

syntax for IF test or AWK for octal

Using korn shell. I am reading a file line by line. If a record has a carriage return (octal 015) then I append the second record to the first record. Not all records have a carriage return. I have the unix shell script working with grep, but when my file has +100,000 records it runs slow. I would... (3 Replies)
Discussion started by: sboxtops
3 Replies

10. Shell Programming and Scripting

Problem with gstat and octal value

Here are a few lines from my script. The problem I am having is that the statement for gstat returns this error: line 43: The statement is coming from gstat. Is there a way to fix it? Apparently -eq 02 is coming up as some octal value, I need it to be recognized as 02. Apparently in... (4 Replies)
Discussion started by: newbie2010
4 Replies
lsMode(3pm)						User Contributed Perl Documentation					       lsMode(3pm)

NAME
Stat::lsMode - format file modes like the "ls -l" command does SYNOPSIS
use Stat::lsMode; $mode = (stat $file)[2]; $permissions = format_mode($mode); # $permissions is now something like `drwxr-xr-x' $permissions = file_mode($file); # Same as above $permissions = format_perms(0644); # Produces just 'rw-r--r--' $permissions = format_perms(644); # This generates a warning message: # mode 644 is very surprising. Perhaps you meant 0644... Stat::lsMode->novice(0); # Disable warning messages DESCRIPTION
"Stat::lsMode" generates mode and permission strings that look like the ones generated by the Unix "ls -l" command. For example, a regular file that is readable by everyone and writable only by its owner has the mode string "-rw-r--r--". "Stat::lsMode" will either examine the file and produce the right mode string for you, or you can pass it the mode that you get back from Perl's "stat" call. "format_mode" Given a mode number (such as the third element of the list returned by "stat"), return the appopriate ten-character mode string as it would have been generated by "ls -l". For example, consider a directory that is readable and searchable by everyone, and also writable by its owner. Such a directory will have mode 040755. When passed this value, "format_mode" will return the string "drwxr-xr-x". If "format_mode" is passed a permission number like 0755, it will return a nine-character string insted, with no leading character to say what the file type is. For example, "format_mode(0755)" will return just "rwxr-xr-x", without the leading "d". "file_mode" Given a filename, do "lstat" on the file to determine the mode, and return the mode, formatted as above. Novice Operation Mode A common mistake when dealing with permission modes is to use 644 where you meant to use 0644. Every permission has a numeric representation, but the representation only makes sense when you write the number in octal. The decimal number 644 corresponds to a permission setting, but not the one you think. If you write it in octal you get 01204, which corresponds to the unlikely permissions "-w----r-T", not to "rw-r--r--". The appearance of the bizarre permission "-w----r-T" in a program is almost a sure sign that someone used 644 when they meant to use 0644. By default, this module will detect the use of such unlikely permissions and issue a warning if you try to format them. To disable these warnings, use Stat::lsMode->novice(0); # disable novice mode Stat::lsMode->novice(1); # enable novice mode again The surprising permissions that are diagnosed by this mode are: 111 => --xr-xrwx 400 => rw--w---- 440 => rw-rwx--- 444 => rw-rwxr-- 551 => ---r--rwt 600 => --x-wx--T 640 => -w------T 644 => -w----r-T 660 => -w--w-r-T 664 => -w--wx--T 666 => -w--wx-wT 700 => -w-rwxr-T 711 => -wx---rwt 750 => -wxr-xrwT 751 => -wxr-xrwt 751 => -wxr-xrwt 755 => -wxrw--wt 770 => r------wT 771 => r------wt 775 => r-----rwt 777 => r----x--t Of these, only 400 is remotely plausible. BUGS
As far as I know, the precise definition of the mode bits is portable between varieties of Unix. The module should, however, examine "stat.h" or use some other method to find out if there are any local variations, because Unix being Unix, someone somewhere probably does it differently. Maybe it "file_mode" should have an option that says that if the file is a symlink, to format the mode of the pointed to file instead of the mode of the link itself, the way "ls -Ll" does. SEE ALSO
o "http://www.plover.com/~mjd/perl/lsMode/". o ls o chmod o stat AUTHOR
Mark-Jason Dominus ("mjd-perl-lsmode@plover.com"). perl v5.10.1 1998-04-20 lsMode(3pm)
All times are GMT -4. The time now is 04:03 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy