Is it possible to put a перенос строки bash in bash after the first word in the file?
The word can be of different lengths, therefore, do not suggest counting characters and placing a hyphen after characters.

  • Yes, it is possible (although it is easier to use a more specialized program like sed / awk ). - aleksandr barakin
  • Purely a shell will be hard, with a cut is already easier - 0andriy
  • um .. echo ololo blablabla | sed "s: :\n:" echo ololo blablabla | sed "s: :\n:" ? - don Rumata
  • Catch: cat | while read ab; do echo $a; if [ "x$b" != "x" ]; then echo "$b"; fi; done cat | while read ab; do echo $a; if [ "x$b" != "x" ]; then echo "$b"; fi; done cat | while read ab; do echo $a; if [ "x$b" != "x" ]; then echo "$b"; fi; done - avp

1 answer 1

sed will definitely save you

 echo "first second third"|sed 's/ /\n/' 
  • And if after the first word \t , and not a space? - avp
  • echo "first second third" | sed 's / [\ t] / \ n /' - Radich
  • And if before the first word is a space? - avp