bash - Scroll a shell script output without piping it into less -


i have bash script.sh. can scroll output this:

$ ./script.sh | less 

but how make output display scrollable automatically, without having pipe through less? in other words, how put functionality right script itself? want execute script this:

$ ./script.sh 

i know might able write different script execute first 1 , pipe output automatically don't want have write script first 1 want do. know mean?

you can write script this:

#!/bin/bash (      script here  ) | less exit $pipestatus  

this pipe script output through less if output terminal (so can ./script.sh > file without paging), , preserves script's exit code.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -