Last active
April 22, 2018 10:00
-
-
Save bmwant/125547b9f9431ffbe90d6b92a087fd1d to your computer and use it in GitHub Desktop.
Same useful shell commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# help set | |
set -e # Exit immediately if a command exits with a non-zero status. | |
set -x # Print commands and their arguments as they are executed. | |
# Export same evironment as process has | |
strings /proc/$PID/environ | |
strings /proc/20316/environ | awk '{ print "export "$1}' >> export_env.sh | |
source export_env.sh | |
# same as above but escape variables in double quotes | |
strings /proc/20316/environ | awk -F '=' '{printf "export %s=\"%s\"\n", $1, $2}' > export_env.sh | |
# Do not save history of current shell | |
history -c | |
# remove previous history | |
rm ~/.bash_history | |
# bash operators and conditions | |
# Return true if a bash variable is unset or set to the empty string: if [ -z "$var" ]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment