ls -l | grep -i status | egrep -o '_.*[0-9]' | cut --complement -c 1
There must be 100s of ways to do this which are much nicer ... LOL
Like ...
ls -l | egrep -o 'status_.*[0-9]' | cut --complement -c1-7
PS: kraljic .... You should really try yourself (post code) when asking a question like this. Show your work and what you tried yourself. You have over 100 posts here. Try yourself before asking, please.
Using external programs (such as cut , *grep , sed , awk or others) are a dire waste of precious resources as well as processes.
It is not clear what the two rev s should accomplish, except making the line non-standard and GNU-dependant.
This is using several non-standard GNU-specific extensions and will therefore only work with the GNU versions of the used utilities. It is dangerous to suggest such solutions, at least when foregoing a proper disclaimer that it won't work in most environments.
This is - in principle - a valid solution although it seems the "#" and "%" operators have been confused, a double quote is missing and a few typos like
f1="${%*_}
will prevent proper execution. It is not necessary to use different variables for the expansion either:
for f in status_*.log; do f="${f%.log}"; printf "%s\n" "${f#status_}"; done
I do condone coding practices mentioned and standard compliance.
One should produce shell code to run anywhere (or any code), if able.
But, the OP posted his operating system is fedora linux and didn't not request a posix compliant shell code to be produced.
As for better way, it is welcomed and encouraged to post better code with proper explanation.
Which member stomp offered.
It is also worth to mention the negligible impact on modern multi-core computers any command provided here has, regardless of quality.
Even with alot of files.
OS, ker|rel, machine: Linux, 3.16.0-7-amd64, x86_64
Distribution : Debian 8.11 (jessie)
pcregrep version 8.35 2014-04-04
More details on pcregrep:
pcregrep a grep with Perl-compatible regular expressions. (man)
Path : /usr/bin/pcregrep
Version : 2014-04-04
Type : ELF 64-bit LSB shared object, x86-64, version 1 ( ...)
Help : probably available with -h,--help
Repo : Debian 8.11 (jessie)