Page 1 of 1

Searching for files with specific protection flags? (Solved)

Posted: Sun Sep 30, 2012 1:08 am
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

Re: Searching for files with specific protection flags?

Posted: Sun Sep 30, 2012 2:06 am
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

Re: Searching for files with specific protection flags?

Posted: Sun Sep 30, 2012 2:29 am
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

Re: Searching for files with specific protection flags?

Posted: Sun Sep 30, 2012 3:05 am
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