From 1f40b5b066d8e100f419b624c9f6ad4ac6cf9f1a Mon Sep 17 00:00:00 2001 From: Eisuke Kawashima Date: Tue, 29 Jul 2025 10:53:34 +0900 Subject: [PATCH] Updated SC2202 (markdown) --- SC2202.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SC2202.md b/SC2202.md index a06a9ce..544c7a8 100644 --- a/SC2202.md +++ b/SC2202.md @@ -4,7 +4,6 @@ ```sh [ current.log -nt backup/*.log ] && echo "This is the latest file" - ``` ### Correct code: @@ -30,7 +29,7 @@ Instead, use a `for` loop to iterate over matching filenames, and apply your con If you know your glob will only ever match one file, you can check this explicitly and use the first file: -``` +```sh set -- backup/*.log [ $# -eq 1 ] || { echo "There are too many matches."; exit 1; } [ file.log -nt "$1" ] && echo "This is the latest file"