| @@ -0,0 +1,38 @@ | |||
| 1 | + | # bash | |
| 2 | + | ||
| 3 | + | * log everything to a file: | |
| 4 | + | ||
| 5 | + | ``` | |
| 6 | + | #!/bin/bash | |
| 7 | + | ( | |
| 8 | + | ... | |
| 9 | + | ) 2>&1 | tee -a file | |
| 10 | + | ``` | |
| 11 | + | ||
| 12 | + | * more subshells may potentially be needed: | |
| 13 | + | ||
| 14 | + | ``` | |
| 15 | + | #!/bin/bash | |
| 16 | + | (( | |
| 17 | + | ... | |
| 18 | + | ) 2>&1) | tee -a file | |
| 19 | + | ``` | |
| 20 | + | ||
| 21 | + | * create a file from a heredoc: | |
| 22 | + | ||
| 23 | + | ``` | |
| 24 | + | cat << EOF > /tmp/yourfilehere | |
| 25 | + | ||
| 26 | + | These contents will be written to the file. | |
| 27 | + | This line is indented. | |
| 28 | + | EOF | |
| 29 | + | ``` | |
| 30 | + | ||
| 31 | + | * find files holding a mountpoint open: | |
| 32 | + | ||
| 33 | + | ``` | |
| 34 | + | $ dmsetup info -c | grep root | |
| 35 | + | ||
| 36 | + | data-root 254 8 L--w 1 1 0 LVM-C6c8ojMf4YLaSZearY2kTlKbL23Hue9RFUByBbzCncyPWemQGMz9EnmHyNjfJdxy | |
| 37 | + | $ lsof | grep "254,8" | |
| 38 | + | ``` | |
simon revised this gist 1 month ago · 01d5a52
1 file changed, 38 insertions