Bash A to Z and 0 to 9

When you run a bash command, e.g. grep, and you need to take in account the letters A to Z and 0 to 9, you can use the following syntax:

for i in {{a..z},{A..Z},{0..9}}; do echo $i; done

From here you can take it further.

It came in hand when I was searching for a value in the session directory and the grep could not accept the * value because there were too many files, so I ran this:

for i in {{a..z},{0..9}}; do grep "something" sess_$i*; done

And I got my results as expected.

Leave a Reply

Your email address will not be published. Required fields are marked *