In BASH I thought to use sed
, but can't figure how to extract pattern instead usual replace.
For example:
FILENAME = 'blah_blah_#######_blah.ext'
number of ciphers (in above example written with "#" substitute) could be either 7 or 10
I want to extract only the number
If all you need is to remove anything but digits, you could use
ls | sed -e s/[^0-9]//g
to get all digits grouped per filename (123test456.ext will become 123456), or
ls | egrep -o [0-9]+
for all groups of numbers (123test456.ext will turn up 123 and 456)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With