How to redirect output of more to a file
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
I would like to pipe the output of tree
command to more
, ignoring the first line. Then redirect the output of more
command to a file. If I type
tree SOME_DIRECTORY | more +2 >> OUTPUT_FILE
The first line still appears in OUTPUT_FILE.
But if I type
tree SOME_DIRECTORY | more +2
the first line doesn't appear on the terminal.
Can anyone point out what mistake I was making ?
shell pipe io-redirection more
add a comment |Â
up vote
0
down vote
favorite
I would like to pipe the output of tree
command to more
, ignoring the first line. Then redirect the output of more
command to a file. If I type
tree SOME_DIRECTORY | more +2 >> OUTPUT_FILE
The first line still appears in OUTPUT_FILE.
But if I type
tree SOME_DIRECTORY | more +2
the first line doesn't appear on the terminal.
Can anyone point out what mistake I was making ?
shell pipe io-redirection more
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I would like to pipe the output of tree
command to more
, ignoring the first line. Then redirect the output of more
command to a file. If I type
tree SOME_DIRECTORY | more +2 >> OUTPUT_FILE
The first line still appears in OUTPUT_FILE.
But if I type
tree SOME_DIRECTORY | more +2
the first line doesn't appear on the terminal.
Can anyone point out what mistake I was making ?
shell pipe io-redirection more
I would like to pipe the output of tree
command to more
, ignoring the first line. Then redirect the output of more
command to a file. If I type
tree SOME_DIRECTORY | more +2 >> OUTPUT_FILE
The first line still appears in OUTPUT_FILE.
But if I type
tree SOME_DIRECTORY | more +2
the first line doesn't appear on the terminal.
Can anyone point out what mistake I was making ?
shell pipe io-redirection more
edited Oct 29 '17 at 9:11
Archemar
19k93366
19k93366
asked Oct 29 '17 at 9:05
Pin-Yen
32
32
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
more (or less) are rather to be used interactively.
use either tail
tree SOME_DIRECTORY | tail +2 >> output_file
this tell tail to list line, starting from 2nd (line Nð2)
or awk
tree SOME_DIRECTORY | awk 'NR>1' >> output_file
this tell awk to print (default action) line whose number (NR: Number Record) is above 1 (you can also use NR>=2
)
or sed (thank to Kusalananda )
tree SOME_DIRECTORY | sed -n '2,$p' >> output_file
where
-n
do not print input2,$
select line from 2 to end of filep
print
Orsed -n '2,$p'
â Kusalananda
Oct 29 '17 at 9:13
Or( read && cat ) <file >newfile
;-)
â Kusalananda
Oct 29 '17 at 9:15
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
more (or less) are rather to be used interactively.
use either tail
tree SOME_DIRECTORY | tail +2 >> output_file
this tell tail to list line, starting from 2nd (line Nð2)
or awk
tree SOME_DIRECTORY | awk 'NR>1' >> output_file
this tell awk to print (default action) line whose number (NR: Number Record) is above 1 (you can also use NR>=2
)
or sed (thank to Kusalananda )
tree SOME_DIRECTORY | sed -n '2,$p' >> output_file
where
-n
do not print input2,$
select line from 2 to end of filep
print
Orsed -n '2,$p'
â Kusalananda
Oct 29 '17 at 9:13
Or( read && cat ) <file >newfile
;-)
â Kusalananda
Oct 29 '17 at 9:15
add a comment |Â
up vote
2
down vote
accepted
more (or less) are rather to be used interactively.
use either tail
tree SOME_DIRECTORY | tail +2 >> output_file
this tell tail to list line, starting from 2nd (line Nð2)
or awk
tree SOME_DIRECTORY | awk 'NR>1' >> output_file
this tell awk to print (default action) line whose number (NR: Number Record) is above 1 (you can also use NR>=2
)
or sed (thank to Kusalananda )
tree SOME_DIRECTORY | sed -n '2,$p' >> output_file
where
-n
do not print input2,$
select line from 2 to end of filep
print
Orsed -n '2,$p'
â Kusalananda
Oct 29 '17 at 9:13
Or( read && cat ) <file >newfile
;-)
â Kusalananda
Oct 29 '17 at 9:15
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
more (or less) are rather to be used interactively.
use either tail
tree SOME_DIRECTORY | tail +2 >> output_file
this tell tail to list line, starting from 2nd (line Nð2)
or awk
tree SOME_DIRECTORY | awk 'NR>1' >> output_file
this tell awk to print (default action) line whose number (NR: Number Record) is above 1 (you can also use NR>=2
)
or sed (thank to Kusalananda )
tree SOME_DIRECTORY | sed -n '2,$p' >> output_file
where
-n
do not print input2,$
select line from 2 to end of filep
print
more (or less) are rather to be used interactively.
use either tail
tree SOME_DIRECTORY | tail +2 >> output_file
this tell tail to list line, starting from 2nd (line Nð2)
or awk
tree SOME_DIRECTORY | awk 'NR>1' >> output_file
this tell awk to print (default action) line whose number (NR: Number Record) is above 1 (you can also use NR>=2
)
or sed (thank to Kusalananda )
tree SOME_DIRECTORY | sed -n '2,$p' >> output_file
where
-n
do not print input2,$
select line from 2 to end of filep
print
edited Oct 29 '17 at 9:17
answered Oct 29 '17 at 9:12
Archemar
19k93366
19k93366
Orsed -n '2,$p'
â Kusalananda
Oct 29 '17 at 9:13
Or( read && cat ) <file >newfile
;-)
â Kusalananda
Oct 29 '17 at 9:15
add a comment |Â
Orsed -n '2,$p'
â Kusalananda
Oct 29 '17 at 9:13
Or( read && cat ) <file >newfile
;-)
â Kusalananda
Oct 29 '17 at 9:15
Or
sed -n '2,$p'
â Kusalananda
Oct 29 '17 at 9:13
Or
sed -n '2,$p'
â Kusalananda
Oct 29 '17 at 9:13
Or
( read && cat ) <file >newfile
;-)â Kusalananda
Oct 29 '17 at 9:15
Or
( read && cat ) <file >newfile
;-)â Kusalananda
Oct 29 '17 at 9:15
add a comment |Â
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%2f401178%2fhow-to-redirect-output-of-more-to-a-file%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