For big scripts, outputs are too long to fit in unix command line. Is there a way to not lose information and see it all in one go on command line?
Asked
Active
Viewed 39 times
0
-
Related, see [Bash command line and input limit](https://stackoverflow.com/q/19354870/608639), [Limit output of all Linux commands](https://stackoverflow.com/q/8335425/608639) and [How to handle more than 10 parameters in shell](https://stackoverflow.com/q/4912733/608639). – jww Jun 08 '18 at 01:41
-
You might want to use [`script(1)`](http://manpages.ubuntu.com/manpages/bionic/en/man1/script.1.html) to make a recording of your shell session. Or [`tee(1)`](http://manpages.ubuntu.com/manpages/bionic/en/man1/tee.1.html) to save the output in a file and also see it on your screen. – glenn jackman Jun 08 '18 at 01:50
1 Answers
1
you can pipe to tee
, and save it to a file:
npm audit fix | tee -a output.txt
The -a
flag means append, so it won't overwrite anything else in output.txt. If you want to overwrite it, leave out -a
.
Example:
[I] sean at goz in ~/d/save
> ruby -v | tee -a output.txt
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
[I] sean at goz in ~/d/save
> cat output.txt
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
[I] sean at goz in ~/d/save
> echo yes | tee -a output.txt
yes
[I] sean at goz in ~/d/save
> cat output.txt
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
yes
[I] sean at goz in ~/d/save
>

shender
- 1,243
- 13
- 17