I need a script that echo one of strings wrapped in quotes.
For example, from variable x="C. Ronaldo" "dos Santos Aveiro" "Cristiano Ronaldo"
i want to echo the third one.
So I want to get output like: "Cristiano Ronaldo"
I've tried it with echo $x | awk '{print $3}'
but it gives me "dos
..
Any help?
By default awk splits records by spaces into fields, given your string, "dos
is the third field. To parse this string the way you desire GNU awk's FPAT
is required. E.g:
awk -v FPAT='"[^"]*"' '{print $3}'