Viewing text in pages on Unix systems: Which command shows a file interactively 24 lines at a time (default page size), allowing forward movement through the content?

Difficulty: Easy

Correct Answer: pg

Explanation:


Introduction / Context:
When inspecting long text files in Unix, paging programs prevent content from scrolling off the screen. Different pagers offer varying controls and defaults; knowing the right tool improves productivity during log analysis and documentation review.



Given Data / Assumptions:

  • The requirement is to view files 24 lines at a time by default.
  • We are using classic Unix utilities commonly found on System V-derived systems.
  • We only need to identify the correct pager, not its advanced options.


Concept / Approach:

The pg command is a historical pager that displays text a page at a time, with a default page length of 24 lines. It accepts commands for navigation and can also follow input from pipelines. Other utilities either print without paging or handle printing tasks, not interactive viewing.



Step-by-Step Solution:

Consider 'pg': a pager that shows text in 24-line pages.Consider 'cat': dumps full content to standard output without paging.Consider 'lp': sends files to the line printer subsystem, not a viewer.Consider '/p': not a standalone Unix command; resembles a DOS switch.Therefore, select 'pg' as the correct answer.


Verification / Alternative check:

Running pg /etc/services presents the file in pages. Pressing space advances one page; q quits. This matches the requirement of viewing 24 lines at a time by default.



Why Other Options Are Wrong:

  • cat: No pagination; unsuitable for large files on a terminal.
  • lp: Sends output to a printer queue, not to the screen.
  • /p: Not a Unix command; that syntax is typical of DOS switches.
  • None of the above: Incorrect because 'pg' fulfills the requirement.


Common Pitfalls:

Confusing 'pg' with 'more' and 'less'. While 'more' and 'less' are modern alternatives (with different defaults and features), the question’s historical default of 24 lines aligns with 'pg'. In many systems, 'less' is preferred for bidirectional navigation, but the specific command requested here is 'pg'.



Final Answer:

pg

More Questions from Unix

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion