nerdexam
Exams010-160Questions#94
LPI

010-160 · Question #94

010-160 Question #94: Real Exam Question with Answer & Explanation

The correct answer is C: zip poems.zip *.txt. The zip command uses the syntax 'zip archive.zip files' where the archive name comes before the list of source files.

The Power of the Command Line

Question

Which of the following commands creates the ZIP archive poems.zip containing all files in the current directory whose names end in .txt?

Options

  • Azip *.txt > poems.zip
  • Bzcat *.txt poems.zip
  • Czip poems.zip *.txt
  • Dzip cfa poems.zip *.txt
  • Ecat *.txt | zip poems.zip

Explanation

The zip command uses the syntax 'zip archive.zip files' where the archive name comes before the list of source files.

Common mistakes.

  • A. The shell redirection operator '>' redirects stdout to a file, but zip writes directly to the archive file specified as an argument, not to stdout, so this produces a corrupt or empty archive.
  • B. zcat is used to decompress and display gzip-compressed files to stdout; it does not create ZIP archives.
  • D. 'cfa' are tar option flags (create, file, append) and are not valid options for the zip utility.
  • E. Piping the raw text output of cat into zip does not produce a valid ZIP archive because zip expects file path arguments, not a raw byte stream on stdin in this invocation form.

Concept tested. zip command syntax for creating archives

Reference. https://linux.die.net/man/1/zip

Topics

#zip command#file compression#archiving#command syntax

Community Discussion

No community discussion yet for this question.

Full 010-160 Practice