Extract values separated by character ( : , . – )

In a bash script if you find yourself with values presented that way

you might want to keep only the second or third of this values that are separated by the : character

like always , in bash there is a lot of ways to accomplish that , but i like to use a one that use the AWK utility because it’s very easy to read and understand.

my list of value is contained in a var name $var let’s extract the third value which is 18.5

Will return the value 18.5

but i can do some math operation in the utility, like :

this will return 326.5 the result of 345 – 18.5

awk is a fast and powerful text editor , there is a lot things you can do with it.

Leave a Comment

Your email address will not be published. Required fields are marked *