i can handle the following case using notepad++ but i need to know how to do it through Linux.



through notepad++ i can replace },{ with },\n{


football}, {swim

How can i handle that through Linux using sed or awk ?


Here is how you would replace every instance of the substring },{ with the string },\n{ (where \n denotes a newline character):

sed 's/},{/},\n{/g'

And here is what it looks like in action:

user@host:~$ echo 'football},{swim},{gold}' \
| sed 's/},{/},\n{/g'


user@host:~$ echo 'football},{swim},{gold}' \
| sed 's/},{/},\n{/g'

| improve this answer | |
  • that's will not make sense with football},{swim},{gold} – αԋɱҽԃ αмєяιcαη Dec 8 '17 at 0:15
  • Sorry, that was unnecessarily complicated. I guess I must be tired. I updated the solution. Is that what you want? – igal Dec 8 '17 at 0:19
  • here we go :D yes that's works :D thanks a lot – αԋɱҽԃ αмєяιcαη Dec 8 '17 at 0:20
  • Does not work for me: echo 'a,b,c' | sed 's/,/\n/g' gives anbnc. – user9645 Jan 7 at 20:42
  • 1
    @user9645 Yeah, that's what I figured. The same thing is true for me on my Mac - doesn't work with BSD sed. I updated the question title and tags to reflect that this question was specific to Linux. – igal Jan 8 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.