Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get string after character [duplicate]

I have a string that looks like this:

 GenFiltEff=7.092200e-01 

Using bash, I would like to just get the number after the = character. Is there a way to do this?

like image 503
user788171 Avatar asked Mar 01 '13 01:03

user788171


People also ask

How do I remove the last character of a string in bash?

Using Pure Bash. Two Bash parameter expansion techniques can help us to remove the last character from a variable: Substring expansion – ${VAR:offset:length} Removing matching suffix pattern – ${VAR%word}

How do I trim a space in bash?

${var/ /} removes the first space character. ${var// /} removes all space characters.


1 Answers

Use parameter expansion, if the value is already stored in a variable.

$ str="GenFiltEff=7.092200e-01" $ value=${str#*=} 

Or use read

$ IFS="=" read name value <<< "GenFiltEff=7.092200e-01" 

Either way,

$ echo $value 7.092200e-01 
like image 112
chepner Avatar answered Sep 29 '22 18:09

chepner