Issue
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.
Solution
sed
looking for all zeros in the beginning of the line + looking for all zeros in the end:
$ sed -e 's/^0+//' -e 's/0+$//' numbers
1234567891
2133123131
4324234243
4356257472
3465645768
3424242423
3543676586
3564578765
6585645646
1212122
1212121122
3232322
Answered By - fedorqui Answer Checked By - Cary Denson (WPSolving Admin)