I'm writing a bash script that generates file names from a spread sheet and then converts existing files to the new ones. I'm already able to do the conversion with a resulting filename 62_02.png
as an example. As you can see it contains integers, an underscore and a file extension (which may be an alphanumeric).
I like how succinct this answer is and I've seen this post using awk
to do a simple conversion of a purely numeric filename but I'm not sure how I can get it to work with the underscore.
If necessary I also have no problem using sed
if that seems practical.
My goal is to have a filename that looks like:
0062_02.png
Many thanks!
Closing information:
I've chosen the solution below for it's greater number of solutions so that another person reading this for their benefit can choose. However, I'd like to mention the answer provided by @cabad is also valid and is probably more friendly a solution to a newbie programmer, IMHO.