You are not logged in.
Pages: 1
im tryin to write a little bash line or script.
it should manage to list all contents recursively of a directory and grep and print all files that have diffrent permissions as specified, same to dirs.
so i started off, no idea how
first thing is
ls -laR
....... ive absolutley no idea how i can start off with scripts like that. dunno where to search or find a good/easy solution to things like that.
plz help me out with my bad scripting knowledge
Offline
Something like that?
ls -laR | grep -v drwx------
Maybe you it's better to use "find" instead.
Greets
dojo
Offline
hey thx!
yay, this is goin right direction.
although a
ls -laR | grep -v -rw-r--r--
doesn't work :?:
and would be cool, if i can define: "leave dirctories out" or "leave files out"
s.th. like
ls -laR | grep -v --without-dirs -rw-r--r--
edit: ok, leaving out directories woulb be with grep-option "-d skip" right?
edit2: want to archive s.th. like this
ls -laR /mnt/media/Musik/ | grep -d skip -v "-rw-r--r--"
but grep then doesnt work bcoz first thing is a "-" . How to go round this :S
Offline
and would be cool, if i can define: "leave dirctories out" or "leave files out"
Look into the 'find' command (man find):
find /mnt/media/Musik -not -type d
edit2: want to archive s.th. like this
ls -laR /mnt/media/Musik/ | grep -d skip -v "-rw-r--r--"
but grep then doesnt work bcoz first thing is a "-" . How to go round this :S
Add a "--":
ls -laR /mnt/media/Musik/ | grep -d skip -v -- "-rw-r--r--"
Offline
mhhhhhhh..... ye i think the find command would be a good one to do that. :? but im stuckin at the last point, trying to find out what parameter or way to do exists to display whole path, i mean, atm i have s.th. like this, but it doesnt work as i want it of course because find only displays from "."
find /mnt/media/Musik -type d | grep -v -- "drwxr-xr-x"
find /mnt/media/Musik -type f | grep -v -- "-rw-r--r--"
those are the two i have now
but i dont find this option that may sound like "display whole path" or s.th. like that.
Offline
O K .. (sry for doublepost, wanted to keep things a bit cleaner :oops: )
Those are the ones that do what i want, although a bit unpretty
find /mnt/media/Musik -type f -printf %m | grep -v 644
find /mnt/media/Musik -type d -printf %m | grep -v 755
Well it works, its just: If with 1st command a file was found with permission not set to 644 it just displays me the current permission but not the filename.
Same to directories with 2nd command.
Would be nice if someone could inform me about this little thingy, would be very thankful. Thx in advance, also to you Cerebral, i think i wouldnt have come so far without help
Offline
Try adding the -ls flag to find:
find /mnt/media/Musik -type d -ls | grep -v "drwxr-xr-x"
Or, you could use find matching even more advanced:
find /mnt/media/Musik -type f -not -perm 0644
Seriously, read up the manpage for find. It's all there.
Offline
Cerebal,.. i got to thank you again. Works wonderfully now
Sure, those manpages But its always a unfriendly way of typing man program-name and than search up and down, up again and stumble across an option, scroll down again and so on.
Isn't there s.th. of a program for search through man-pages?
cheers, detto
Offline
Well, whatever pager you use to view manpages can probably search - try typing / followed by a search string when you view a manpage, like:
/perm
Basically vim-style searching. That's the one I've seen most supported.
Offline
:shock: uff...damn, workin. also highliting all results, awesome! thx so much
Offline
Pages: 1