Convert UNIX rights in a number in a sh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert UNIX rights in a number in a sh script
# 1  
Old 04-13-2015
Convert UNIX rights in a number in a sh script

Hello,

i'm trying to write a script sh to convert the rights of a folder or file in a number.
Explain:

Code:
ls -l = rwxrwxrwx

so i must display 777.

Do you known where i can find so convert script

Thanks

Moderator's Comments:
Mod Comment Use code tags, thanks.

Last edited by zaxxon; 04-13-2015 at 08:06 AM..
# 2  
Old 04-13-2015
What have you tried so far?
# 3  
Old 04-13-2015
Convert

Hello,

thanks . I tried the command stat -c "%a %n" but it didn't work.

So i'm checking

Thanks
# 4  
Old 04-13-2015
hi

firstly what is your system ? (if unix ? - > which platform or linux ?)
this info required for more help Smilie

if your linux variants maybe try
Code:
ls -l |awk 'NR>1{j=10;for(i=1;i<=10;i++){j--;if(substr($1,i,1)~"[rwx]")o+=2^j;};printf "%o",o;o=0;$1="";}1' OFS='\t'

if your system is unix which platform and which shell ?

regards,
ygemici
# 5  
Old 04-13-2015
Convert

Hello,

thanks for your feedback.

I'm working on Unix on AIX on an sh script.

Thanks
# 6  
Old 04-13-2015
Quote:
Originally Posted by steiner
Hello,

thanks for your feedback.

I'm working on Unix on AIX on an sh script.

Thanks
chek this maybe its helpful for u.Smilie

AIX and HP-UX equivalent of Linux stat command

regards
ygemici
# 7  
Old 04-13-2015
Convert

Hello,

the istat command didn't work the result is the same rwx.......

Also the Solaris script didn't work on my AIX sh script (with changes to AIX)

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Convert ascii character values to number that comes between the numbers in UNIX

I have variable that contains multiple values of number and also include overpunch(i.e. # $ % etc) character so we want to replace it with numbers. here are the example: Code: 11500#.0# 28575$.5$ 527#.7# 42".2" 2794 .4 2279!.9! 1067&.7& 926#.6# 2279!.9! 885".5" 11714$.4$ 27361'.1'... (1 Reply)
Discussion started by: nadeemrafikhan
1 Replies

2. Shell Programming and Scripting

Need a script for automation the convert a lot number audio files to another format

I have a lot number audio files in the MP3 proprietary format, I want to convert them to 'opus' the free and higher quality format, with keep metadata also. My selection command-line programs are SoX (Sound eXchange) for convert MP3 files to 'AIFF' format in order to keep quality and metadata*... (1 Reply)
Discussion started by: temp-usr
1 Replies

3. UNIX for Dummies Questions & Answers

Question about UNIX file rights

Hello experts, i am a Unix beginner and to test the rules of file rights (rwx) i created the file /root/testdir/subdir/test.sh and set the rights of testdir,subdir, test.sh (using chmod) to various configurations in order to get an idea in which case you need which rights. Test commands... (5 Replies)
Discussion started by: mike_bn
5 Replies

4. Shell Programming and Scripting

Convert unix script in to php

Hi All, I have one shell script and like to convert into GUI for user creation..Any way to convert shell script into php? Please find the below for my script. $ more user.sh #!/bin/ksh set -x pwfile="/etc/passwd" shadowfile="/etc/shadow" gfile="/etc/group" ######Want to check... (0 Replies)
Discussion started by: susindram
0 Replies

5. Shell Programming and Scripting

need script to convert number in hexadecimal

hi , i need a script to convert number into hexadecimal base for example: 237=>ED it s very important for me thank you in advance for you help (5 Replies)
Discussion started by: mips
5 Replies

6. Shell Programming and Scripting

convert unix script to perl

Hi, I have these lines in a unix script: FILEONE = /<filepath1>/<filename1.txt> FILENEW = /<filepath2>/<filename2.txt> head -5 $FILEONE | sed '1d' > $FILENEW PARAM1 = `cat $FILENEW | awk '{print $2;}' ` echo "Param1 Value: $PARAM1" What's the correct syntax of the above lines if same... (2 Replies)
Discussion started by: gholdbhurg
2 Replies

7. UNIX for Dummies Questions & Answers

Unix access rights

Hi, Is it true that if I am not the root I can not select access permissions to a file that I own so that my friend (who also isn't the root) can access that file? And is it true that the only way to accomplish it is to ask the root to "put" my friend into "my" group? Then I could simply set... (1 Reply)
Discussion started by: rudo
1 Replies

8. Shell Programming and Scripting

how to convert unix .ksh script to windows .batch script

I am using awk in my .ksh script but when I am trying to run in windows its not recognising awk part of the ksh script , even when I changed it to gawk it does not work, this is how my .ksh and .bat files look like. thanx. #!/bin/ksh egrep -v "Rpt 038|PM$|Parameters:|Begin |Date: |End... (1 Reply)
Discussion started by: 2.5lt V8
1 Replies

9. SuSE

UNIX - Linux NFS Rights need Help

Hello, I am running a Suse Linux server and I want to set up a NFS Server for a few Unix machines. For the root account at the unix client it works fine but it doesn't work for other users who have no root rights. I've used the no_root_squash and the rw option in the etc/export file. My folder... (7 Replies)
Discussion started by: Ald-Edv
7 Replies

10. Shell Programming and Scripting

C Shell Script to convert a number into minutes

Could anyone tell me how to write a C shell script according to the following requirement. Write a C shell script convertmin which will read in a number, thought of as representing minutes, and print out the number of hours/minutes it represents so: Note: you are required to check exception... (1 Reply)
Discussion started by: Ringo
1 Replies
Login or Register to Ask a Question