Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
simple regex matching
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
numerodix
l33t
l33t


Joined: 18 Jul 2002
Posts: 743
Location: nl.eu

PostPosted: Wed Jan 12, 2005 7:34 pm    Post subject: simple regex matching Reply with quote

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
View user's profile Send private message
hjnenc
Veteran
Veteran


Joined: 15 Aug 2004
Posts: 1599
Location: Vienna, Austria

PostPosted: Wed Jan 12, 2005 7:57 pm    Post subject: Reply with quote

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
View user's profile Send private message
numerodix
l33t
l33t


Joined: 18 Jul 2002
Posts: 743
Location: nl.eu

PostPosted: Wed Jan 12, 2005 8:01 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum