[Notes] in respect of such learning Linux - Chapter IV Lesson

vim using
    a cursor at a position of the insert
    i is inserted in the current cursor position
    o create a blank line below cursor
    dd delete (shear) the cursor is located
    5dd removed (cut) 5 lines starting from point
    yy copy cursor line
    copy 5yy 5 lines starting from point
    n to display the search command is positioned in a string of
    N display to locate the search command string on a
    previous operation u revocation
    P previously deleted (dd) or copy (yy) had paste data after the cursor

Line mode
    : w save
    and: q
    : q! Forced to quit without saving
    : wq! Forced save and exit
    : set nu show line numbers
    : set nonu not display line numbers
    : Run command
    : Integer Integer Line Jump to
    : s / one / two first current cursor row is replaced with one TWO
    : S / one / two / g all one current cursor line replaced TWO
    :% S / one / two / g will replace the full text of all one into TWO
    ? In the text string from the bottom of the search string
    / strings from top to bottom of the search string in the text


Escape character
    backslash (\) using a backslash character string variable becomes simple
    single quotation marks ( '') wherein all variables escaped as a simple string of
    double quotes ( "") wherein the variables reserved properties, without any escaping
    back quotes ( `) to return the result of the commands executed

shell script
    requires three elements:
    ! 1. Declare # / bin / bash bash interpreter to tell the system to execute scripts which use
    2. Comment # explain what the intent of the script is executed, usually just write
    3. script command is this the main content of the script

    After executing the script can carry parameters, but also depends on whether the script calls these parameters
    ./open.sh ie qq wx
    script variables:
    the name of the script $ 0
    $ # script How many arguments
    $ * corresponding to all positions the parameters
    $? the last command return value
    $ 1, $ 2, $ 3 ...... after corresponding script parameter values

The user determines parameter

  File and logical test operator
[-d / etc / fstab]
echo $? Command to see if the above judgment result, if so, output 1, and if not, the output 0
    -d test whether the file is a directory type
    -e test whether a file exists
    whether -f judge for the general file
    -r test whether the current user has permission to read the
    -w test whether the current user has permission to write
    -x test whether the current user has permission to perform

    && Logical AND
    || Logical OR
    ! Logical NOT

  Integer comparison operators
[10 -gt 10]
echo $ see if the command is a result of the above determination, if it is, the output 1, if not, outputs 0?
    -Eq is equal
    -ne not equal
    -gt is greater than
    - whether lt smaller than
    if less than or equal to -le
    whether greater than or equal to -ge

String comparison operators
[-z $ String] String variables to determine whether an empty value
echo $? Command to see if the result is above judgment, if it is, the output 1, if not, then output 0
    = compare strings whether content the same
    ! = Comparative string contents are different
    -z determines whether the contents of the string is empty

Conditional control statements

if conditional statement
read -p "Enter your score (0-100 ):" GRADE # ( which is an input statement, allows you to enter a number between 0-100)
if [$ -ge GRADE 85] && [$ GRADE - 100 Le]; the then
echo "$ the GRADE IS Excellent"
elif [$ -ge the GRADE 70] && [$ -le the GRADE 84]; the then # (multi-increase determination condition middle of elif item)
echo "$ Pass the GRADE IS"
the else
echo "$ GRADE IS Fail" 
fi # (must be at the end of the fi)

for circulation
for UNAME in `cat users.txt` # (written for this cycle conditions)
do # (must start with this do, which is mandatory)
the above mentioned id $ UNAME &> / dev / null
IF [$? -eq 0 ]
the then
echo "Already EXISTS"
the else
useradd $ UNAME &> / dev / null
echo "$ pASSWD" | passwd --stdin $ UNAME &> / dev / null
? IF [$ -eq 0]
the then
echo "$ UNAME, the Create Success "
the else
echo" $ UNAME, the Create failure "
fi
fi
DONE # (mandatory end type)

while loop condition
PRICE = $ (expr $% 1000 the RANDOM)
TIMES = 0
echo "in real commodity prices between 0-999, Guess What?"
while to true
do # (hard to determine the starting order identifier)
the Read - p "Please enter the number of price your guess:" INT
the let tIMES ++
IF [$ INT -eq $ pRICE]; the then
echo "Congratulations, you answered correctly, the actual price is $ pRICE"
echo "you have a total guess the $ tIMES times"
Exit 0
elif [$ INT -gt $ PRICE]; the then
echo "! too high"
the else
echo "! too low"
fi
DONE # (the end of the paradigm)


case test condition statement
read -p "Enter a character, and press Enter to confirm:" KEY
case "$ KEY" in
| [az] [AZ])
. "You enter the letters" echo
;; # (particularly magical a condition dividing paradigm)
[0-9])
echo "your input is digital."
;;
*) # (the last else command identification similar to the default cycle)
echo "you enter a space, the function keys or other control characters. "
esac

Scheduled tasks
at one time a scheduled task to add commands
    -l to see what a one-time task has planned
    at 23:00 after a one-time set up a scheduled task 23:00 (input, will enter an editing mode, enter the command you want to execute directly , then press Ctrl + d to write the end of the scheduled task)
    or the write echo "systemctl restart httpd" | AT 23:30
atrm delete the one-off scheduled tasks (with the back directly to the serial number)
    atrm 2 need to delete a scheduled task 2

Periodic crontab scheduled tasks
    -e to create, edit
    -l to view the current presence of scheduled tasks
    -r delete
    -u edit other users scheduled task
periodically scheduled task format

* * * * *   

Guess you like

Origin www.cnblogs.com/ly570/p/10961076.html