Not confident with the rationale but the page was blank

jammer3d
2017-01-05 15:19:28 -05:00
parent f9c3ff26b7
commit 957afc9dd2

20
SC2010.md Normal file

@@ -0,0 +1,20 @@
## Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.
### Problematic code:
```sh
ls /directory | grep target_file_pattern
```
### Correct code:
```sh
ls /directory/target_file_pattern
```
### Rationale:
Matching non-alphanumeric characters with grep may require escaping. Typically it is cleaner to use the built in pattern matching or another command like `find`
### Exceptions:
None