From 5f5b1a865958c00ad4cd40b5bf10bdfafd39fe54 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sun, 13 Nov 2022 11:39:53 -0800 Subject: [PATCH] Updated SC2012 (markdown) --- SC2012.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SC2012.md b/SC2012.md index 6f2c7e3..e9e1d9c 100644 --- a/SC2012.md +++ b/SC2012.md @@ -12,7 +12,7 @@ NUMGZ="$(ls -l *.gz | wc -l)" ### Correct code: ```sh -find . -maxdepth 1 -name '*.txt' -user "$USER" # Using the names of the files +find ./*.txt -user "$USER" # Using the names of the files ``` ```sh gz_files=(*.gz) @@ -38,6 +38,8 @@ It shows three seemingly identical filenames, and did you spot the time format c #### Just the filenames, ma'am +(Note that `-maxdepth` is not POSIX, but can be simulated by having the expression call `-prune` on all directories it finds, e.g. `find ./* -prune -print`) + `ls` can usually be replaced by `find` if it's just the filenames, or a count of them, that you're after. Note that if you are using `ls` to get at the contents of a directory, a straight substitution of `find` may not yield the same results as `ls`. Here is an example: ```