View previous topic :: View next topic |
Author |
Message |
kachaffeous Tux's lil' helper
Joined: 07 Jun 2002 Posts: 86
|
Posted: Thu Jan 30, 2003 9:04 pm Post subject: Help! Regular expression to find core files |
|
|
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 |
|
|
rac Bodhisattva
Joined: 30 May 2002 Posts: 6553 Location: Japanifornia
|
Posted: Thu Jan 30, 2003 10:14 pm Post subject: |
|
|
How about: Code: | $ find ./ -regex '.*/core\(\.[0-9]+\)?' |
_________________ For every higher wall, there is a taller ladder |
|
Back to top |
|
|
kachaffeous Tux's lil' helper
Joined: 07 Jun 2002 Posts: 86
|
Posted: Thu Jan 30, 2003 11:14 pm Post subject: |
|
|
Code: | find ./ -regex '.*/core\(\.[0-9]+\)?' |
Thanks! Works good on my gentoo box. Will test it tomorrow @ work on concurrent |
|
Back to top |
|
|
kachaffeous Tux's lil' helper
Joined: 07 Jun 2002 Posts: 86
|
Posted: Fri Jan 31, 2003 3:10 pm Post subject: |
|
|
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 |
|
|
rtn Guru
Joined: 15 Nov 2002 Posts: 427
|
Posted: Fri Jan 31, 2003 3:20 pm Post subject: |
|
|
Or compile gnu find.
--rtn |
|
Back to top |
|
|
|