Reputation: 149
I used jq
to extract value from JSON file I stored the values in on variable as string
var=$(Jq-command)
# var now contain
# "Serge" "Haroche" "David J." "Wineland"
I want a script to split this string every two word and create new lines, so i can't get as output
output:
Serge Haroche
David J Wineland
I'm kinda new im not really confortable with awk/sed and i couldn't with cut.
Upvotes: 0
Views: 181
Reputation: 764
try this sed script
var='"Serge" "Haroche" "David J." "Wineland"'
echo $var|sed -n 's/"\([^"]\+\)" "\([^"]\+\)" */\1 \2\n/gp'
Output
Serge Haroche
David J. Wineland
to remove last \n
echo -n $var|sed -n 's/"\([^"]\+\)" "\([^"]\+\)" */\1 \2\n/gp'
Upvotes: 2