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"