mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2012 (markdown)
@@ -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:
|
||||
|
||||
```
|
||||
|
Reference in New Issue
Block a user