View previous topic :: View next topic |
Author |
Message |
numerodix l33t
Joined: 18 Jul 2002 Posts: 743 Location: nl.eu
|
Posted: Wed Jan 12, 2005 7:34 pm Post subject: simple regex matching |
|
|
Was wondering if you could help me figure this out.. I have a bunch of directories named d* and I'm trying to match them with a regex but for some reason it doesn't work..
Code: | $ ls
afile
bfile
donedir
dtwodir
ffile |
Code: | for i in $(ls --color=none | egrep \md --colour=never)
do
cd $i
dosomething
done |
Before I added the --color switch to ls, it did match fine but then the cd command didn't work, I presume because of the color output. So I added that and now it won't even match. _________________ undvd - ripping dvds should be as simple as unzip |
|
Back to top |
|
|
hjnenc Veteran
Joined: 15 Aug 2004 Posts: 1599 Location: Vienna, Austria
|
Posted: Wed Jan 12, 2005 7:57 pm Post subject: |
|
|
Try
Code: | ls --color=none | egrep ^d --colour=never |
But in simple cases like this you can also do
Code: | for i in d* ; do
... |
|
|
Back to top |
|
|
numerodix l33t
Joined: 18 Jul 2002 Posts: 743 Location: nl.eu
|
Posted: Wed Jan 12, 2005 8:01 pm Post subject: |
|
|
Oh lifesaver, thanks a lot! I tried with ^ in the past but with the colors on it didn't work at the time, have been playing around with this for an hour now.
Gracias! _________________ undvd - ripping dvds should be as simple as unzip |
|
Back to top |
|
|
|