Searching for + sign in a string using awk

Hi All,

My query is:
I have string say xyz+ how to determine that whether it ends with a + sign or not using awk command.

# awk '/\+$/' file

Try this one:

sed -n '/+$/p' a

Bro,

wudnt the code that u mentioned search for "xyz+" sting only if it is at the end of a line ? pls correct me if I am wrong

what if the string which has to be searched happens to be in the middle of a line. like
asd sdvdh dfh "xyz+" shfks dfbv

yes only at the end of a string, as OP requested

a little modification then, but the regexp remains

...
 for ( i=1;i<=NF;i++) {
  if ( $i ~ /+$/ ) {
    # do something
  }
 }
..

Shorter one:

> echo "asd sasa+ sd+lvdh dfh xyz+ shfks dfbv ddfd+\c"|awk 'match($0,/\+$/)' RS=" "       
sasa+
xyz+
ddfd+

Or:

> echo 'asd sasa+ sd+lvdh dfh xyz+ shfks dfbv ddfd+'|awk 'gsub(/\n/," ");match($0,/\+$/)' RS=" " 
sasa+
xyz+
ddfd+

Or:

> echo "asd sasa+ sd+lvdh dfh xyz+ shfks dfbv ddfd+"|awk 'gsub(/\n/," ");index($0,"+") == (length) ' RS=" "                       
sasa+
xyz+
ddfd+

Or:

> echo "asd sasa+ sd+lvdh dfh xyz+ shfks dfbv ddfd+\c"|awk 'index($0,"+") == (length) ' RS=" "               
sasa+
xyz+
ddfd+