# bash * log everything to a file: ``` #!/bin/bash ( ... ) 2>&1 | tee -a file ``` * more subshells may potentially be needed: ``` #!/bin/bash (( ... ) 2>&1) | tee -a file ``` * create a file from a heredoc: ``` cat << EOF > /tmp/yourfilehere These contents will be written to the file. This line is indented. EOF ``` * find files holding a mountpoint open: ``` $ dmsetup info -c | grep root data-root 254 8 L--w 1 1 0 LVM-C6c8ojMf4YLaSZearY2kTlKbL23Hue9RFUByBbzCncyPWemQGMz9EnmHyNjfJdxy $ lsof | grep "254,8" ```