What have you tried?
Here's a quick guess at a crude solution:
Assume that we're always dealing with just numbers, and there is always at least one digit and not more than four.
So, the allowable filenames include:
9
23
456
2345
09
034
0231
0002
I put this in a file called "numpad"
First, use this to add 3 zeros to each one:
Code:
[mherring@herring_desk ~]$ sed 's/.*/000&/' numpad
0009
00023
000456
0002345
00009
000034
0000231
0000002
now, we use sed to truncate to the last 4 characters:
Code:
[mherring@herring_desk ~]$ sed 's/.*/000&/' numpad | sed -r 's/.*(.{4})$/\1/'
0009
0023
0456
2345
0009
0034
0231
0002
As I said, crude. Wait awhile and someone will have something a bit more elegant.