Find newly created *.ready regular files under /srv/import without waiting for a database refresh.
Which command is appropriate?
find traverses the specified start path at execution time, so it sees current files independently of the locate database.
Detailed explanation
locate '/srv/import/*.ready'Incorrect. locate may miss a file created after the last database update.
Incorrect. locate may miss a file created after the last database update.
whereis readyIncorrect. whereis locates command binaries and manuals.
Incorrect. whereis locates command binaries and manuals.
find /srv/import -type f -name '*.ready'Correct. find /srv/import -type f -name '*.ready' searches the current tree.
Correct. find /srv/import -type f -name '*.ready' searches the current tree.
which readyIncorrect. which searches PATH for an executable named ready.
Incorrect. which searches PATH for an executable named ready.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); touch "$tmp/new.ready" "$tmp/skip.txt"; find "$tmp" -type f -name '*.ready' -printf '%f\n'; rm -rf "$tmp"Expected result
new.readyKey points
- find is a live traversal
- locate is a database snapshot
- -type f selects regular files
Notes
- Environment: GNU findutils 4.x / 一時ディレクトリ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.