Linux and Command-Line Basics

Which of the following describes the files found when find /data -name "*.log" -mtime +7 -size +100M is run with GNU find?

  1. AFiles whose names end in .log, last modified 8 or more days ago, and larger than 100 MiB
  2. BFiles whose names end in .log, last modified within 7 days, and larger than 100 MiB
  3. CFiles whose names end in .log, created 8 or more days ago, and larger than 100 MiB
Show answer and explanation

Answer: A. Files whose names end in .log, last modified 8 or more days ago, and larger than 100 MiB

-name "*.log" selects names ending in .log, -mtime the time the contents were last modified, and -size +100M sizes larger than 100 MiB. -mtime compares the elapsed time counted in 24-hour units with the fraction discarded, so +7 means "more than 7", that is, 8 days (192 hours) or more; a file only 7 days and 23 hours old is not selected. Files modified within 7 days are selected with -mtime -7. *.log is quoted so that the shell does not expand it first into file names in the current directory.

  • A. Correct. +7 means a day count, with the fraction discarded, greater than 7, that is, 8 or more days.
  • B. Selecting files modified within 7 days is -mtime -7. + means "more than" and - means "less than".
  • C. -mtime compares the time the contents were last modified, not the time the file was created.
Practice this topic Back to topic

Books on Linux and Command-Line Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Linux and Command-Line Basics questions

  1. When stopping a process that has stopped responding, it is recommended to first use "kill <process ID>" and to use "kill -9 <process ID>" only if that does not end it. Which of the following is the reason?
  2. While a long-running ./sim.sh is running in a terminal, you want to use other commands in the same terminal. Which of the following is what happens when you press Ctrl+Z and then run bg?
  3. On a server reached over SSH, a long-running task was started with "./run.sh &", and when the connection was closed the task stopped too. Which of the following is the most appropriate way to start it so that it keeps running after the connection is closed?
  4. When the two lines above are run in a shell, which of the following are the characters shown?
  5. When the commands above are run in order, which of the following is the output of the two echo commands?