Shell Paging Through Files
Paging through a file means reading it one screen at a time. The less command shows one screen, and it waits while you read.
Open a file in less
less shows the first screen of notes.txt. Press q to quit.
less notes.txtShow a short file at once
less -F prints a short file and quits at once.
less -F notes.txtPage through a second file
less -F prints report.txt and quits at once.
less -F report.txtExample
less -F data.csvKey points
- less: a command that pages through a file one screen at a time.
- Use less to read a long file without it scrolling past.
- Press q to quit less and return to the shell.
- Press the space bar in less to move to the next screen.
- Use less -F to show a short file at once, with no waiting.
In this example, less -F shows data.csv at once, because the file is short. The four lines print on the screen, and less quits, so the shell prompt returns.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
Which key quits less?