Reputation: 43
I have a bunch of files that are of this form: abc_512_004.dat all i need to do is to delete the zeros so that the filename becomes abc_512_4.dat
I have tried all kinds of things including rename 's/^0+//' *.dat and cannot seem to know what to do.
Many thanks for your help!
Upvotes: 0
Views: 135
Reputation: 1080
You can use replace method. You could do
'abc_512_004.dat'.replace("0","");
This will result in 'abc_512_4.dat'. Let me know if it didn't helps.
Upvotes: 1