You can use less command to display files with paging through text one screenful at a time. You can use less command in the interactive mode which enables you to perform multiple operations on the output screen as listed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
## create a long file with 200 lines > myfile; i=1; while [ $i -le 200 ]; \ do echo "$i" >> myfile; ((i++)); done cat myfile ## displays the content of myfile at once less myfile ## displays one screenful at a time ## enter ==> scroll one line at a time ## space ==> scroll one screenful at a time ## q ==> exit ps -ax | less ## also works with pipe ## less command provides an interactive mode to interact with the output less myfile ## enters into the interactive mode ## below are some commands that can be issued in interactive mode ## for a complete list, please refer the above table. ## command => h H (Display this help) ## command => q :q Q :Q ZZ (Exit.) ## command => e ^E j ^N CR (Forward one line) ## command => y ^Y k ^K ^P (Backward one line) ## command => f ^F ^V SPACE (Forward one window) ## command => b ^B ESC-v (Backward one window) ## command => ESC-) RightArrow (Left one half screen width) ## command => ESC-( LeftArrow (Right one half screen width) ## command => /pattern (Search forward for matching line) ## command => ?pattern (Search backward for matching line) ## command => n (Repeat previous search) ## command => N (Repeat previous search in reverse direction) ## command => &pattern (Display only matching lines) ## command => p % (Go to beginning of file) rm myfile |