Multiple choice technology operating systems

Display only files with ".zip" extension from the current directory

  1. ls -ltr *.zip

  2. ls -ltr | grep "zip$"
  3. 1 and 2

  4. None

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

ls -ltr *.zip directly lists files ending in .zip. ls -ltr | grep "zip$" lists all files, then filters for lines ending in 'zip'. Both achieve the same result for .zip files - the shell glob matches the pattern, and the regex anchors to the end.