Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Help! Regular expression to find core files
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
kachaffeous
Tux's lil' helper
Tux's lil' helper


Joined: 07 Jun 2002
Posts: 86

PostPosted: Thu Jan 30, 2003 9:04 pm    Post subject: Help! Regular expression to find core files Reply with quote

Trying to get a regular expression to to match core files but not regular files(using find). This is what I'm trying:

I want to match the following: (core or core followed by a period and any amount of numbers)
core
core.1
core.1234

but not: (core followed by a ext, a core man page or word with core)
core.xpm
core.1.z
coreword

I have tried the following expressions
Code:
find . -name core\.?[0-9]*


This matches core.1234 but not core or core.1


Code:
find . -name "core*[0-9]"


This matches core.1 and core.1234 but not core.

I have tried many more but just can't get the right combo.
Back to top
View user's profile Send private message
rac
Bodhisattva
Bodhisattva


Joined: 30 May 2002
Posts: 6553
Location: Japanifornia

PostPosted: Thu Jan 30, 2003 10:14 pm    Post subject: Reply with quote

How about:
Code:
$ find ./ -regex '.*/core\(\.[0-9]+\)?'

_________________
For every higher wall, there is a taller ladder
Back to top
View user's profile Send private message
kachaffeous
Tux's lil' helper
Tux's lil' helper


Joined: 07 Jun 2002
Posts: 86

PostPosted: Thu Jan 30, 2003 11:14 pm    Post subject: Reply with quote

Code:
 find ./ -regex '.*/core\(\.[0-9]+\)?'


Thanks! Works good on my gentoo box. Will test it tomorrow @ work on concurrent :)
Back to top
View user's profile Send private message
kachaffeous
Tux's lil' helper
Tux's lil' helper


Joined: 07 Jun 2002
Posts: 86

PostPosted: Fri Jan 31, 2003 3:10 pm    Post subject: Reply with quote

Well the Concurrent version of find doesn't support -regex so I'm using this which works (wanted a 1-liner though ) :)
Code:
for core in `find / -name "core*" -print ; do
file $core|grep -q "MSB core file"
 if [ $? -eq 0 ]
  rm $core
 fi
done
Back to top
View user's profile Send private message
rtn
Guru
Guru


Joined: 15 Nov 2002
Posts: 427

PostPosted: Fri Jan 31, 2003 3:20 pm    Post subject: Reply with quote

Or compile gnu find. :)

--rtn
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