Reputation: 7910
I would like to turn "{something: here}"
into "[{something: here}]"
For example:
$ echo "{something: here}" | magic_command
$ [{something: here}]
I want to do it all as part of a bash one liner using STDIN.
Seems simple enough. Any ideas? I'm drawing a blank :(
Upvotes: 1
Views: 932
Reputation: 361685
Add one pair of brackets around everything:
echo "{something: here}" | echo "[$(cat)]"
Surround each line separately:
echo "{something: here}" | awk '{print "[" $0 "]"}'
Upvotes: 4
Reputation: 31560
You could try it with sed:
echo "{something: here}" | sed 's/\(.*\)/[\1]/'
Upvotes: 2