Updated SC2012 (markdown)

Vidar Holen
2022-11-13 11:39:53 -08:00
parent 28e8f87bce
commit 5f5b1a8659

@@ -12,7 +12,7 @@ NUMGZ="$(ls -l *.gz | wc -l)"
### Correct code: ### Correct code:
```sh ```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 ```sh
gz_files=(*.gz) 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 #### 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: `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:
``` ```