โ† All 010-160 Flashcard Decks

Searching and Extracting Data Flashcards

6 cards from real 010-160 practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 6 Searching and Extracting Data flashcards as text
  1. A system administrator needs to find all files in the `/var/log` directory that have been modified in the last 7 days. Which of the following commands will accomplish this task?

    Answer: find /var/log -mtime -7

    The `find` command is used to search for files and directories. The `/var/log` argument specifies the starting directory for the search. The `-mtime` option filters files based on their last modification time in days, and `-7` specifically looks for files modified within the last 7 days.

  2. Which command is used to display the first 10 lines of a text file named `report.txt`?

    Answer: head report.txt

    The `head` command, by default, displays the first 10 lines of a specified file. The `tail` command shows the last lines, `cat` displays the entire file, and `less` is a pager for viewing files page by page.

  3. A user wants to search for the case-insensitive string "error" within the `system.log` file. Which of the following commands is the correct way to perform this search?

    Answer: grep -i "error" system.log

    The `grep` command is the standard tool for searching text using patterns. The `-i` option makes the search case-insensitive, so it will match "error", "Error", "ERROR", etc.

  4. You have a comma-separated value (CSV) file named `data.csv` and you need to extract only the third column. Which command will achieve this?

    Answer: cut -d ',' -f 3 data.csv

    The `cut` command is used to remove sections from each line of files. The `-d ','` option specifies that the delimiter is a comma, and `-f 3` specifies that the third field (column) should be extracted.

  5. To count the number of lines containing the word "warning" in the file `application.log`, which command should be used?

    Answer: grep -c "warning" application.log

    While `grep` is used for searching, the `-c` option modifies its behavior to output a count of matching lines instead of the lines themselves. `wc -l` would count all lines, and `grep -n` would show line numbers with the matches.

  6. A user needs to combine two commands. They want to list all files in the current directory and then use the output of that command to search for files containing the word "config". Which character should be used to connect the two commands?

    Answer: |

    The pipe `|` symbol is used to create a pipeline between commands. It takes the standard output of the command on its left (e.g., `ls`) and uses it as the standard input for the command on its right (e.g., `grep config`).