Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to insert a newline \n after x numbers of words, with AWK or Sed

I have this in one line:

We were born in the earth beyond the land

I want it in 3 words lines, to be like this:

We were born
in the earth 
beyond the land
like image 202
user2275669 Avatar asked Dec 27 '22 05:12

user2275669


1 Answers

$ xargs -n3 < file
We were born
in the earth
beyond the land

$ egrep -o '\S+\s+\S+\s+\S+' file 
We were born
in the earth
beyond the land
like image 162
Chris Seymour Avatar answered Dec 31 '22 14:12

Chris Seymour