mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2024 (markdown)
@@ -6,7 +6,7 @@ or "Use `sudo cat file | ..`" instead of `<` to read.
|
||||
|
||||
### Problematic code:
|
||||
|
||||
```
|
||||
```sh
|
||||
# Write to a file
|
||||
sudo echo 3 > /proc/sys/vm/drop_caches
|
||||
|
||||
@@ -19,7 +19,7 @@ sudo wc -l < /etc/shadow
|
||||
|
||||
### Correct code:
|
||||
|
||||
```
|
||||
```sh
|
||||
# Write to a file
|
||||
echo 3 | sudo tee /proc/sys/vm/drop_caches > /dev/null
|
||||
|
||||
@@ -45,14 +45,14 @@ Note: there is nothing special about `tee`. It's just the simplest command that
|
||||
|
||||
Truncating:
|
||||
|
||||
```
|
||||
```sh
|
||||
echo 'data' | sudo dd of=file
|
||||
echo 'data' | sudo sed 'w file'
|
||||
```
|
||||
|
||||
Appending:
|
||||
|
||||
```
|
||||
```sh
|
||||
echo 'data' | sudo awk '{ print $0 >> "file" }'
|
||||
echo 'data' | sudo sh -c 'cat >> file'
|
||||
```
|
||||
|
Reference in New Issue
Block a user