一. 网址参考
5. linux复制指定目录下的全部文件到另一个目录中,linux cp 文件夹
6. Shell重定向 &>file、2>&1、1>&2 、/dev/null的区别
二. 实践
1. nginx的启动脚本中的start-stop-daemon用法, /etc/init.d/nginx:
# Try to extract nginx pidfile PID=$(cat /etc/nginx/nginx.conf | grep -Ev '^s*#' | awk 'BEGIN { RS="[;{}]" } { if ($1 == "pid") print $2 }' | head -n1) if [ -z "$PID" ]; then PID=/run/nginx.pid fi if [ -n "$ULIMIT" ]; then # Set ulimit if it is set in /etc/default/nginx ulimit $ULIMIT fi start_nginx() { # Start the daemon/service # # Returns: # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON --test > /dev/null || return 1 start-stop-daemon --start --quiet --pidfile $PID --exec $DAEMON -- $DAEMON_OPTS 2>/dev/null || return 2 } test_config() { # Test the nginx configuration $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1 } stop_nginx() { # Stops the daemon/service # # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=$STOP_SCHEDULE --pidfile $PID --name $NAME RETVAL="$?" sleep 1 return "$RETVAL" }
2. bash补全不区分大小写
~/.inputrc文件
$include /etc/inputrc
# Case-insensitive tab completion
set completion-ignore-case on