โ† All Linux Flashcard Decks

Text Processing & Editors Flashcards

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

Read the first 7 Text Processing & Editors flashcards as text
  1. Which vim command saves the current file and exits the editor?

    Answer: :wq

    :wq writes (saves) the file and then quits vim in a single command.

  2. What does the `grep -i` flag do?

    Answer: Performs a case-insensitive search

    The -i flag tells grep to ignore case differences when matching patterns, so 'Hello' matches 'hello'.

  3. Which sed command replaces ALL occurrences of 'foo' with 'bar' on each line?

    Answer: sed 's/foo/bar/g' file

    The 'g' flag at the end of the sed substitution command makes it replace every occurrence on each line, not just the first.

  4. What does `awk '{print $2}' file` output?

    Answer: The second field (column) of each line

    In awk, $2 refers to the second whitespace-delimited field of each input record.

  5. Which command displays the last 10 lines of a file by default?

    Answer: tail

    The tail command shows the last 10 lines of a file by default; use -n to specify a different count.

  6. What does `sort -n` do differently from `sort` without flags?

    Answer: Sorts by numeric value instead of lexicographically

    The -n flag causes sort to compare values as numbers, so '10' correctly sorts after '9' rather than before it.

  7. Which command counts lines, words, and bytes in a file?

    Answer: wc

    The wc (word count) command reports the number of lines, words, and bytes in a file by default.