Bash : extracting part of a string

You probably want to extract it rather than remove it. You can use the Parameter Expansion to extract the value:

var="Memory Used: 19.54M"
var=${var#*: }            # Remove everything up to a colon and space
var=${var%M}              # Remove the M at the end

Note that bash can only compare integers, it has no floating point arithmetics support.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)