Hey,
I was hoping for some help, my point was to search for all "core" files with only digits in the extension
Eg:
1) core.153498 < He should find it
2) core.1 < He should find it
3) core.919jasj < shouldn't find it
4) core.abdijs < shouldn't find it
find . -name 'core.[0-9]*' -printf "%s \t %p \n" -type f
What am I doing wrong here?
He finds the first 3 examples and I just want it to find the first 2..
Thanks for your time,
Bruno
The only way I could see to get what you want is by using to separate find lines as below:
find . -name 'core.[0-9]' -printf "%s \t %p \n" -type f
find . -name 'core.[0-9]*[0-9]' -printf "%s \t %p \n" -type f
A scripting guru will no doubt come up with a one liner...
this will help you:b:
find . -type f -name "core.*" -ls -long|awk -F"\/" 'split($NF,A,".")A[2] !~ /[aA-zZ]/{print $NF}'
rikxik
4
$ ls core.*
core.1 core.153498 core.919jasj core.abdijs
$ find . -name 'core.[0-9]*' -type f -print|grep "core\.[0-9]*$"
./core.153498
./core.1
You can change find's matching rules from glob to regular expression or if you prefer awk "-regextype posix-awk"
find . -regextype posix-egrep -name 'core.[0-9]*$' -printf "%s \t %p \n" -type f
ls | egrep "core\.[0-9]+$"
rikxik
7
That assumes all the files are in the same top level directory. But that gives this idea:
$ find . -name "core.*" -print
./abc/core.200
./abc/core.12xyz
./core.153498
./core.1
./core.919jasj
./core.abdijs
$ ls -R | egrep "core\.[0-9]+$"
core.1
core.153498
core.200
Assuming we don't have any directories startig with "core." otherwise we will have to add some more parts in the pipeline.