expr command to extract words

how to use expr command to retrieve all the words before the equal sign "=" with shell script

expr is not used for that. see the man page for detaild. awk may work for this task.

bash substitution

~$ A="fJH DFKGF= ,jfhF"
~$ echo  ${A%=*}
fJH DFKG

Here is an example of how to do what you want to do:

$ A="foo=bar"
$ echo $A
foo=bar
$ expr "$A" : '\(.*\)=.*'
foo

From IEEE Std 1003.1:2008

1 Like