How to extract "Matthew" from "mtjoseph:6/MKTCzMS/YU.:10974:10060:Matthew"
+5
A:
echo "mtjoseph:6/MKTCzMS/YU.:10974:10060:Matthew"| awk -F ':' '{print $5}'
eumiro
2010-10-08 18:44:06
Googled for *awk split by char*, returned here, oh! my answer is already posted! ;)
takeshin
2010-10-08 18:48:35
or `print $NF` to generically take the last field
glenn jackman
2010-10-08 19:42:52
A:
I find echo "mtjoseph:6/MKTCzMS/YU.:10974:10060:Matthew"| cut -d: -f5 simpler.
bobmcn
2010-10-08 18:53:11
Someone I highly respect once said "there is a whole generation of programmers who think awk is just a synonym for cut(1)".
jbinto
2010-10-08 18:58:26
A:
Or, just let the shell do it (assuming bash)
entry="mtjoseph:6/MKTCzMS/YU.:10974:10060:Matthew"
name="${entry##*:}"
echo "$name" # ==> Matthew
glenn jackman
2010-10-08 19:42:15