• sed

C.biancheng.net/view/4028.h…

Sed is a great tool for file processing. It is a pipe command itself, which is mainly processed in units of behavior. It can replace, delete, add and select rows of data

The -i option of sed allows you to modify the file content directly. For example, if you have a 1 million line file and you want to add some text in line 100, vim might go crazy because the file is so big. Sed is very convenient.

Example 1: Regular expression

/sbin/ifconfig eth0 //eth0 Link encap:Ethernet HWaddr 00:90:CC: a6:34:84 //inet addr:192.168.1.100 Bcast:192.168.1.255 Mask: 255.255.255.0 / / UP BROADCAST RUNNING MULTICAST MTU: 1500 Metric: 1 / sbin/ifconfig eth0 | grep 'inet addr' | sed 's / ^. * addr: / / g' / / 192.168.1.100 Bcast: 192.168.1.255 Mask: 255.255.255.0Copy the code

^ matches from scratch,. Matches any single character except newline character \n, and * matches the preceding subexpression zero or more times.

Example 2: sed s replaces the script command

Format: [address] s/pattern/replacement/flags. The common flags are as follows:

About ConfigPoeCipher. Sh in N possible explanation: www.cnblogs.com/ultranms/p/…

  • The $1

    $0 is the name of the shell script itself;

    $1 is the first argument passed when the shell script is running;

    $2 is the second argument passed when the shell script is running;

    $? Is a special variable that gets the exit status of the previous command or the return value of the previous function.

    C.biancheng.net/view/808.ht…

    Strictly speaking, the return keyword in Shell functions is used to indicate the exit status of the function, not the return value of the function; Unlike other programming languages, the Shell does not have keywords that deal specifically with return values.

  • The cat with the grep

    The cat filename | grep XXXX filter show only contains lines of XXXX

  • awk

    placeholder

  • if [ -f
    h o m e / home/
    1]

    1, if condition judgment keyword

    2. [

    -f file comparison operator, true if filename is a regular file

    4, home fetch the value of the variable, if the.sh file does not have this is the user system variable will be fetched! You can run echohome on the terminal to fetch the value of the variable, and if the.sh file does not contain the value, it will fetch the user system variable! You can execute echo home in the terminal to fetch the value of the variable, if the.sh file does not have that value will fetch the user system variable! You can do echoHome on the terminal and see what’s the path

    5, 1 Take the first input parameter. For example :shxxx.sh111 then 1 takes the first input parameter. For example, run sh xxx.sh 111. In this case, 1 takes the first parameter. Example :shxxx.sh111 then the value of 1 is 111

  • unset

    The Linux unset command is used to delete a variable or function.

  • -ne

    Shell basic operators, relational operators. Checks if two numbers are not equal. Returns true if they are not equal.

  • declare

    Declare a variable. -r sets the variable to read-only. Declared variables can be unset.

  • sys.argv

    Python can use sys. Argv of sys to get command-line arguments. Ex. :

$python3 test.py arg1 arg2 arg3 The number of arguments is four. Parameter list: [' test. P y ', 'arg1, arg2, arg3'] script name: test. PyCopy the code
Arguments can be accessed as a list, such as sys.argv[1] for arg1.Copy the code
  • -nr

    -n does not print the contents of the pattern space to the screen, that is, -r is not automatically printed. -e uses extended regular expressions

  • getfacl

    Gets a directory or file access control list. Syntax: getfacl [- parameter] file

  • setfacl

    Set the file access control list. The setfacl -m command is commonly used, for example, setfacl -m u:admin:r,g::– File name. Note the use in conjunction with chmod.

  • python -c

    Using python -c in the shell environment, you can call Python code from the command line. C stands for command.

  • ps -ef | grep eds-f

    The ps command displays a process. -e Displays all processes. -f is in full format.

  • zgrep -a

  • Source, sh, bash,./ Execute shell basic differences

    Blog.csdn.net/lihuaichen/…