Help using the "find" command


 
Thread Tools Search this Thread
Operating Systems AIX Help using the "find" command
# 1  
Old 05-03-2010
Help using the "find" command

Hi all, Please i wanna find all the files which has a write permission for others "********w*" by using 'find' command doesn't matter the other permissions (Owner,group) are.
I tried
Code:
“find / -perm --2 -print”
“find / -perm --6 -print”
“find / -perm --3 -print”

but did not work with AIX 5.3 which i use.

Please any help..

Thanks in Advance.

Last edited by Scott; 05-04-2010 at 10:07 AM.. Reason: Please use code tags
# 2  
Old 05-03-2010
This works on my linux box:
Code:
#find / -perm /002

# 3  
Old 05-03-2010
Thanks for your quick reply, it tried the command but did not work Smilie

Code:
<aixtestserver@/temp/perm>ls -l
total 40
-rwxr-xr-x   1 root     system           10 May 03 13:01 1111
-rwx---r--   1 root     system           10 May 03 13:08 2222
-rwxrwxrwx   1 root     system           10 May 03 13:07 3333
-rwx------   1 root     system           10 May 03 13:08 4444
-rwxrwx-wx   1 root     system           10 May 03 13:08 5555
<aixtestserver@/temp/perm>find . -perm /002 -print
find: 0652-085 Specify a valid -perm argument.
<aixtestserver@/temp/perm>find . -perm \002 -print
<aixtestserver@/temp/perm>


Last edited by pludi; 05-03-2010 at 08:54 AM.. Reason: code tags please
# 4  
Old 05-03-2010
GREAT! Smilie
Code:
#find . -perm -o=w

o stand for others

The below is the solution from your link Mommy, I found it! — 15 Practical Linux Find Command Examples (link removed)

Quote:
For this example, let us assume that the directory contains the following files. Please note that the file-permissions on these files are different.
Code:
# ls -l
total 0
-rwxrwxrwx 1 root root 0 2009-02-19 20:31 all_for_all
-rw-r--r-- 1 root root 0 2009-02-19 20:30 everybody_read
---------- 1 root root 0 2009-02-19 20:31 no_for_all
-rw------- 1 root root 0 2009-02-19 20:29 ordinary_file
-rw-r----- 1 root root 0 2009-02-19 20:27 others_can_also_read
----r----- 1 root root 0 2009-02-19 20:27 others_can_only_read

Find files which has read permission to group. Use the following command to find all files that are readable by the world in your home directory, irrespective of other permissions for that file.

Code:
# find . -perm -g=r -type f -exec ls -l {} \;
-rw-r--r-- 1 root root 0 2009-02-19 20:30 ./everybody_read
-rwxrwxrwx 1 root root 0 2009-02-19 20:31 ./all_for_all
----r----- 1 root root 0 2009-02-19 20:27 ./others_can_only_read
-rw-r----- 1 root root 0 2009-02-19 20:27 ./others_can_also_read

Find files which has read permission only to group.
Code:
# find . -perm g=r -type f -exec ls -l {} \;
----r----- 1 root root 0 2009-02-19 20:27 ./others_can_only_read

Find files which has read permission only to group [ search by octal ]
Code:
# find . -perm 040 -type f -exec ls -l {} \;
----r----- 1 root root 0 2009-02-19 20:27 ./others_can_only_read


Last edited by bakunin; 05-05-2010 at 03:40 AM.. Reason: reformatted the post for better readability.
# 5  
Old 05-03-2010
Dr. Matrix, thanks for that link. It has a lot of really good examples. Have 1000 bits.
# 6  
Old 05-04-2010
Reference the earlier posts. The hyphen prefix to the -perm parameter causes find to search on a mask rather than exact permissions.
To find files writeable by "others":
Code:
find . -type f -perm -000002 -print

The leading zeros can be omitted from this syntax.
This gives the same effect:
Code:
find . -type f -perm -2 -print

# 7  
Old 05-04-2010
you can do this by awk also

Code:
ls -lrt |awk '{x=substr($1,9,1)}{if(x=="w"){print $0}}'


Last edited by Scott; 05-04-2010 at 10:07 AM.. Reason: Code tags, please...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find . -path "*_nobackup*" -prune -iname "*.PDF" \( ! -name "*_nobackup.*" \)

These three finds worked as expected: $ find . -iname "*.PDF" $ find . -iname "*.PDF" \( ! -name "*_nobackup.*" \) $ find . -path "*_nobackup*" -prune -iname "*.PDF" They all returned the match: ./folder/file.pdf :b: This find returned no matches: $ find . -path "*_nobackup*" -prune... (3 Replies)
Discussion started by: wolfv
3 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

How to find a file which are not ends with ".zip" and which are ends with "*.log*" or "*.out*"?

I am new to bash/shell scripting. I want to find all the files in directory and subdirectories, which are not ends with “.zip” and which are contains in the file name “*.log*” or “*.out*”. I know below command to get the files which ends with “.log”; but I need which are not ends with this... (4 Replies)
Discussion started by: Mallikgm
4 Replies

4. Shell Programming and Scripting

Find lines with "A" then change "E" to "X" same line

I have a bunch of random character lines like ABCEDFG. I want to find all lines with "A" and then change any "E" to "X" in the same line. ALL lines with "A" will have an "X" somewhere in it. I have tried sed awk and vi editor. I get close, not quite there. I know someone has already solved this... (10 Replies)
Discussion started by: nightwatchrenba
10 Replies

5. Shell Programming and Scripting

Using sed to find text between a "string " and character ","

Hello everyone Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Discussion started by: haggismn
10 Replies

6. Shell Programming and Scripting

Problem with "find" and "grep" command

I want to list all files/lines which except those which contain the pattern ' /proc/' OR ' /sys/' (mind the leading blank). In a first approach I coded: find / -exec ls -ld {} | grep -v ' /proc/| /sys/' \; > /tmp/list.txt But this doesn't work. I got an error (under Ubuntu): grep:... (5 Replies)
Discussion started by: pstein
5 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. UNIX for Advanced & Expert Users

command for recently modified files - "find" command not working

I have three files a.txt , b.txt , c.txt in a directory called my_dir1 .These files were created before two or three months . I have a tar file called my_tar1.tar which contains three files a.txt , b.txt , d.txt . Somebody untarred the my_tar1.tar into my_dir1 directory. So existing two files were... (1 Reply)
Discussion started by: joe.mani
1 Replies

9. Shell Programming and Scripting

"find command" to find the files in the current directories but not in the "subdir"

Dear friends, please tell me how to find the files which are existing in the current directory, but it sholud not search in the sub directories.. it is like this, current directory contains file1, file2, file3, dir1, dir2 and dir1 conatins file4, file5 and dir2 contains file6,... (9 Replies)
Discussion started by: swamymns
9 Replies

10. Shell Programming and Scripting

grep to find content in between curly braces, "{" and "},"

problem String ~~~~~~~~~~~~~~~~~~ icecream= { smart peopleLink "good" LC "happy" , smartpeopleLink "dull" LC "sad" } aend = {smart vc4 eatr kalu} output needed ~~~~~~~~~~~~~~~~~~ smart peopleLink "good" LC "happy" , smartpeopleLink "dull" LC "sad" smart vc4... (4 Replies)
Discussion started by: keshav_rk
4 Replies
Login or Register to Ask a Question