Experts i have a text file where i have some mathematic data and there i've hyphen - which i need to replace into 0 and MB at the end of numbers which also need be removed so, i can get only numbers.
Below is sample data in a file called file1:
Data:
$ cat file1
3708MB 5073MB 5153MB 0MB
- 63097MB 9939MB 53376MB
- 817MB 681MB 271MB
- 2655MB 692MB 2112MB
What i have tried:
$ /bin/sed 's/\r//g; s/-/0/g; s/MB//g' tt4
3708 5073 5153 0
0 63097 9939 53376
0 817 681 271
0 2655 692 2112
Or just to get columnize it better way via column command ...
$ /bin/sed 's/\r//g; s/-/0/g; s/MB//g' tt4| column -t
3708 5073 5153 0
0 63097 9939 53376
0 817 681 271
0 2655 692 2112
Is there a better to make sure strictly that only replace hyphen - which do not have anything in prefix and suffix and same for removing MB only if its and the end of the numbers.