How can I add lines to document every four lines?
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
I want to add a new line every four lines of a document.
For example:
abc
def
ghi
jkl
mno
pqr
stu
vw
xyz
should become:
abc
def
ghi
jkl
mno
pqr
stu
vw
xyz
text-processing
New contributor
Advil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
4
down vote
favorite
I want to add a new line every four lines of a document.
For example:
abc
def
ghi
jkl
mno
pqr
stu
vw
xyz
should become:
abc
def
ghi
jkl
mno
pqr
stu
vw
xyz
text-processing
New contributor
Advil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
up vote
4
down vote
favorite
up vote
4
down vote
favorite
I want to add a new line every four lines of a document.
For example:
abc
def
ghi
jkl
mno
pqr
stu
vw
xyz
should become:
abc
def
ghi
jkl
mno
pqr
stu
vw
xyz
text-processing
New contributor
Advil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
I want to add a new line every four lines of a document.
For example:
abc
def
ghi
jkl
mno
pqr
stu
vw
xyz
should become:
abc
def
ghi
jkl
mno
pqr
stu
vw
xyz
text-processing
text-processing
New contributor
Advil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Advil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 5 mins ago


Isaac
7,89711137
7,89711137
New contributor
Advil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 40 mins ago
Advil
211
211
New contributor
Advil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Advil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Advil is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
try this command:
awk ' print; NR % 4 == 0 print ""; '
add a comment |Â
up vote
2
down vote
With (GNU) sed
:
sed '0~4G'
man sed explains ~ as:
first ~ step
Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)
With awk
, probably:
awk '1 ; NR%4==0 printf"n" '
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
try this command:
awk ' print; NR % 4 == 0 print ""; '
add a comment |Â
up vote
3
down vote
try this command:
awk ' print; NR % 4 == 0 print ""; '
add a comment |Â
up vote
3
down vote
up vote
3
down vote
try this command:
awk ' print; NR % 4 == 0 print ""; '
try this command:
awk ' print; NR % 4 == 0 print ""; '
answered 37 mins ago
Goro
7,72753371
7,72753371
add a comment |Â
add a comment |Â
up vote
2
down vote
With (GNU) sed
:
sed '0~4G'
man sed explains ~ as:
first ~ step
Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)
With awk
, probably:
awk '1 ; NR%4==0 printf"n" '
add a comment |Â
up vote
2
down vote
With (GNU) sed
:
sed '0~4G'
man sed explains ~ as:
first ~ step
Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)
With awk
, probably:
awk '1 ; NR%4==0 printf"n" '
add a comment |Â
up vote
2
down vote
up vote
2
down vote
With (GNU) sed
:
sed '0~4G'
man sed explains ~ as:
first ~ step
Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)
With awk
, probably:
awk '1 ; NR%4==0 printf"n" '
With (GNU) sed
:
sed '0~4G'
man sed explains ~ as:
first ~ step
Match every step'th line starting with line first. For example, ``sed -n 1~2p'' will print all the odd-numbered lines in the input stream, and the address 2~5 will match every fifth line, starting with the second. first can be zero; in this case, sed operates as if it were equal to step. (This is an extension.)
With awk
, probably:
awk '1 ; NR%4==0 printf"n" '
edited 4 mins ago
answered 31 mins ago


Isaac
7,89711137
7,89711137
add a comment |Â
add a comment |Â
Advil is a new contributor. Be nice, and check out our Code of Conduct.
Advil is a new contributor. Be nice, and check out our Code of Conduct.
Advil is a new contributor. Be nice, and check out our Code of Conduct.
Advil is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f474172%2fhow-can-i-add-lines-to-document-every-four-lines%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password