010-150 · Question #11
Which of the following commands can be used to view a file and do search operations within it while viewing the contents?
The correct answer is A. less. The less command is an interactive pager that allows viewing file contents and performing forward and backward searches within the displayed content.
Question
Which of the following commands can be used to view a file and do search operations within it while viewing the contents?
Options
- Aless
- Bfind
- Cgrep
- Dreport
- Esee
How the community answered
(37 responses)- A81% (30)
- B11% (4)
- C5% (2)
- D3% (1)
Why each option
The `less` command is an interactive pager that allows viewing file contents and performing forward and backward searches within the displayed content.
`less` is an interactive terminal pager that displays file contents one screen at a time and supports search operations using `/` for forward search and `?` for backward search while viewing the file. Unlike editors, it opens files read-only, and unlike `more`, it allows bidirectional navigation through the content.
`find` is used to locate files and directories within a filesystem based on criteria such as name or type, not to view or search within file contents.
`grep` searches for patterns within files and prints matching lines to stdout, but it does not provide an interactive viewing interface for browsing the full file.
`report` is not a standard Linux/Unix command for viewing files.
`see` is not a standard Linux/Unix command for viewing or searching file contents.
Concept tested: Interactive file viewing and search with less
Source: https://man7.org/linux/man-pages/man1/less.1.html
Topics
Community Discussion
No community discussion yet for this question.