I have file like this:
pup@pup:~/perl_test$ cat numbers
1234567891
2133123131
4324234243
4356257472
3465645768000
3424242423
3543676586
3564578765
6585645646000
0001212122
1212121122
0003232322
In the above file I want to remove the leading and trailing zeroes so the output will be like this
pup@pup:~/perl_test$ cat numbers
1234567891
2133123131
4324234243
4356257472
3465645768
3424242423
3543676586
3564578765
6585645646
1212122
1212121122
3232322
How to achieve this? I tried sed
to remove those zeroes. It was easy to remove the trailing zeroes but not the leading zeroes.
Help me.
perl -pe 's/^0+ | 0+$//xg' numbers
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With