*nix script snippets that are useful/clever By TrentPosted on 2018-07-182019-04-17Leave a Comment on *nix script snippets that are useful/clever For the record – these are lookups – NOT my creations. I will add more as I go #Backup & clear history DATE=`date +%Y%m%d-%H%M` mv ~/.zsh_history{,.$DATE} cat /dev/null > ~/.zsh_history #HDD space (without clutter) df -h | grep -v "tmp\|udev" #send contents into a file (you need to \escape any \$variables within the CONTENTS+COMMANDS) cat < /path/to/file/to/create CONTENTS+COMMANDS EOF #inline string replacement in config file sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config; #OR (IF you have perl installed) perl -pi -e 's|SELINUX=enforcing|SELINUX=disabled|' /etc/selinux/config; #To list TCP listening ports, with name of each listener’s daemon and its PID sudo netstat -plnt | grep -i listen