shell commonly used tips

#!/bin/bash
# Encounters a variable that does not exist, terminate the execution of the script
set -o nounset
# Encounter execution error, terminate script execution
set -o errexit

# Wrapper functions necessary
# Readonly static variable declarations and local variables modified
Use # $ () instead of `(backtick)
Use # [[]] instead of []

#echo not the only debugging method
# The script syntax checking -n
bash -n test.sh
# -V track with the implementation of each command script
bash -v test.sh
# -X tracking script with the implementation of each command, and the additional information that augments
bash -x test.sh
# Print shell input is read line
#set -o verbose
Print command before execution command #
set -o xtrace

# Output Current time: date when minutes and seconds
date "+%Y-%m-%d %H:%M:%S"
# And user interactions, reading input variables
read x

  

Guess you like

Origin www.cnblogs.com/sai564/p/12601090.html