Searching for files with specific protection flags? (Solved)

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1744
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Searching for files with specific protection flags? (Solved)

Post by nbache »

Has anybody ever found a way to find files with specific protection flags set/reset? Either using AmigaOS commands or 3rd party tools?

Right now I need to find any read-protected files on a partition, but I could imagine other situations where you'd want to find files with other flags or combinations of flags set or reset.

Any suggestions - other than writing my own? I guess I could, but I'd rather not if some solution is out there already. :-)

Best regards,

Niels
Last edited by nbache on Sun Sep 30, 2012 11:50 pm, edited 1 time in total.
User avatar
Slayer
Beta Tester
Beta Tester
Posts: 851
Joined: Tue Dec 21, 2010 4:19 am
Location: New Zealand

Re: Searching for files with specific protection flags?

Post by Slayer »

I think the answer could lie with the List Command but whether or not the pattern matching can be directed to protection flags is beyond my general trivia 8-) since it already covers subdirectories with its ALL flag

Perhaps List could be altered to provide this function for you :geek:

For a work around just to give you a listing you could go

List ALL > Ram:List.txt

then cd to Ram:

grep -e -----wed List.txt > Ram:List2.txt

Of course this isn't perfect since some files will be missing the e flag and others might have one or more of hspa flags set but perhaps the following grep command line can be modified to just pass the line to output if the 5th character = a -

grep -e ^....-... List.txt > Ram:List2.txt
~Yes I am a Kiwi, No, I did not appear as an extra in 'Lord of the Rings'~
1x AmigaOne X5000 2.0GHz 2gM RadeonR9280X AOS4.x
3x AmigaOne X1000 1.8GHz 2gM RadeonHD7970 AOS4.x
Spectre660
Posts: 1538
Joined: Sat Jun 18, 2011 3:16 pm
Location: Montserrat

Re: Searching for files with specific protection flags?

Post by Spectre660 »

Something like this the files you want will endup at the to of the list in the file TO.txt

list sys: lformat %A-%S%S ALL > RAM:FOO.TXT
SORT FROM RAM:FOO.TXT COLSTART 5 TO RAM:TO.TXT
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1744
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: Searching for files with specific protection flags?

Post by nbache »

Yep, thanks, both of you. I had forgotten about grep and regexps. That does help to interpret List's LFORMAT %A output.

And sorting would surely work as well.

In both cases, however, it would involve a rather large temporary file, but maybe I can get away with a pipe such as:

List ALL LFORMAT "%A %P%N" | grep -e ^....-

(Note: Not yet tested.) EDIT: Now tested, works fine (with or without the "-e").

Best regards,

Niels
Post Reply