.: Denotes any character
*: Matches the previous character, A * indicates: 0 or more A
+: Matches the preceding character to represent 1 or more preceding characters
?: matches the preceding character to represent 0 or more preceding characters
#! /bin/bash #!/bin/sh Opening
Comments:
: <<! Eof!
Write code here
! Eof!
Can be the SH 1.sh to execute the script, or the right to chmod a+x 1.sh and then./1.sh
Sh-x: Can be used to debug scripts
Date +%y: Year (M-month, D-Day, H-hour, M-minute, S-second, s = number of seconds from January 1, 1970 to present, W week, W is now the first week)
Date-d " -1day" + "%F%T": Indicates this time of yesterday
Export can declare global variables, which can take effect in child shells
$: script itself
$#: The script uses several parameters
$n: Represents the nth parameter
If
Format: note [] There are spaces on both sides
if Conditions
Then
echo "true";
elif [condition]; then
echo "false";
Else
echo "Error";
fi
>:GT, <:it, >=:ge, <=:le, ==:eq,!=:ne
-a means that &&,-o represents | |
If determine file, directory properties
[-F file] Determines if it is a normal file, and there is
[-D file] Determines if it is a directory and exists
[-E file] to determine whether files or directories exist
[-R File] to determine if the document is readable
[-W file] Determines whether the file is writable
[-X file] Determines whether the file is executable
exec >/tmp/$d. Log 2>&1: You can append the actual error to the/tmp/*.log
Generally written on top of the script, you can output all the logs executed by the script
when a variable is defined n=1 do not add spaces on either side of the equals sign
June 15, 2015
By:champly
Shell Script-1