You can say:
awk '/Ghostscript/{print $3}' inputfile
to get the third field from the line containing Ghostscript.
When you say:
gs_version=`awk -F'|' 'Ghostscript/ {version=$3; print version}' $str`
there is:
- a missing
/
before Ghostscript - moreover, since you want
awk
to read from a string you need to make use of herestring. - fields are delimited by whitespace by default so you don't need to supply one (not sure why you used
|
, though)
gs_version=$(awk '/Ghostscript/ {version=$3; print version}' <<< "$str")
Although there was simpler ways to get the version information.