Using Ubuntu.
I have a directory, with some sub directories, which may have some files with names formatted like this:
core.foo.1234 core.bar.65432
So, they all start with ‘core’. then a process name, then the PID number, which is usually 4 or 5 digits.
My Python based tool uses two ‘find’ commands to find them, like this:
the_cmd4 = "find " + directory_name + " -name "core.*.[0-9][0-9][0-9][0-9]""; the_cmd5 = "find " + directory_name + " -name "core.*.[0-9][0-9][0-9][0-9][0-9]"";
So, this is essentially calling the ‘find’ tool like this:
find . -name "core.*.[0-9][0-9][0-9][0-9]"
There must be a way to specify a ‘find’ with variable number of number characters – instead of doing it in two steps.
Is there?
Thanks in advance.
Advertisement
Answer
I think you can filter again with grep
which supports more powerful RE:
find . -name "core*" | grep "core.*.[0-9]+"