I would like to grep or cat only files that begin with a specific number and are in a range until a specific number, e.g.:
abc_server.2022-04-09-34.log
until
abc_server.2022-04-09-50.log
How can I do this?
I tried using cat:
cat abc_server.2022-04-09-3*
but obviously it does not give me the expected results.
CodePudding user response:
You can use Brace Expansion for numeric ranges. Here's an example:
$ echo file_{09..12}.txt
file_09.txt file_10.txt file_11.txt file_12.txt
Note that this is not wildcard matching. The expansion happens irrespective of whether files with those names exist.
So, if you use cat file_{09..12}.txt
, the four filenames shown above will be passed as arguments to the cat
command.