I am trying to extract numbers from file names that follow a specific pattern:
file-8923489_something.txt another_file-8923489_something.txt some-other_file-8923
Is it possible to do this using operators only, ...
$ filename="file-8923489_something.txt" $ file=${foo//[^0-9]/} $ echo $file 8923489
You might want to refer to Shell Parameter Expansion.
Alternatively, you can say:
$ file=$(tr -dc '[[:digit:]]' <<< "$filename") $ echo $file 8923489