Search This Blog

2013-07-09

SED Tips and Tricks

Cutting off the trailing Unit of size measurement
The following will find the unit MiB and cut it off an attached size

So 1000MiB will turn to 1000 with no trailing units
sed 's/MiB*$//'

To remove all alphanumeric characters from a line:
sed 's/[^0-9]*//g'

This will work by continuously replacing anything that is not a digit at the start of the string.

No comments:

Post a Comment