How to extract a substring from a string

Hi,

I have an input string say for example:

ABC,DEF,IJK,LMN,...,XYZ

The above string is comma delimited. Now I have to extract the last part after the comma i.e. XYZ.

:b:

The AWK way:

# echo "ABC,DEF,IJK,LMN,...,XYZ" | awk -F"," '{print $NF}'
XYZ

=o)

The Perl way:

echo "ABC,DEF,IJK,LMN,...,XYZ" | perl -e '@x=split/,/,<>; print $x[-1]'

The SED way... :wink:

echo "ABC,DEF,IJK,LMN,...,XYZ" | sed 's/.*,\(.*\)$/\1/g'

--ahamed