Multiple choice technology operating systems

What command used to search a string in a file?

  1. ls

  2. more

  3. grep

  4. search

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

The grep command (Global Regular Expression Print) is the standard Unix/Linux utility for searching text patterns within files. The 'ls' command lists directory contents, 'more' displays file contents page by page, and 'search' is not a standard Unix command for this purpose.

AI explanation

grep (Global Regular Expression Print) searches for a pattern or string within one or more files and prints matching lines. ls lists directory contents (no content searching), more is a pager for viewing file content page-by-page (no search filtering by default), and 'search' is not a standard Unix command. grep is the standard, POSIX-defined tool for this exact task.