Linux Study Notes (iii) -- Summary of Shell scripts

Source: Internet
Author: User


1. vi Editor Shortcut Key memo [Ctrl] + [ud] Move up/down half page n <space> shift right n characters H/M/L move to the top/center/bottom line u [Ctrl] + r restore and redo. (point) Repeat the previous action: e! Restore the file to the original state [Ctrl] + v Block Selection
2. bash Shell basic env Environment Variable set environment variable and other variables export make the variable into environment variable, take effect in the subroutine read-p followed by the prompt character, -t wait seconds declare declares the attribute of the variable-a is defined as an array-I is defined as an integer number-x is the same as the export, change to Environment Variable-r read-only attribute history view historical command/etc/issue Terminal interface string (use man issue or man mingetty to view the meaning of special code/etc/motd user to get the message system after login) set Value: important variables such as/etc/profile PATH, USER, MAIL, HOSTNAME, HISTSIZE, and umask in/etc/sysconfig/i18n are required to read other files, such as/etc/profile. d and/etc/inputrc login Shell: The shell obtained by the user when logging on to the Linux System Corresponds to the last data in/etc/passwd. For example, if I want the user to directly open vi after atom login, change the last item of the line corresponding to atom in/etc/passwd to/usr/bin/vi.
3. summary of common Linux text processing tools a) cut-d 'delimiter'-f fields, take out the cut-c field range in the fields segment separated by a separator and take out a fixed character range in units B) cat/etc/passwd | sort-t ': '-k 3-n-t, separator, default is the tab key;-k, the number of fields;-n, use "pure number" to sort c) other, wc [-lwm]; uniq [-ic]; tee [-a], bidirectional redirection d) String Conversion command: tr, col, join (merge the same data in two files), paste (directly paste the two rows together), expand (Convert [tab] to Space key) e) split file f) -(minus signs) Some commands need to use the file name for processing. stdin and stdout can be replaced by minus signs.
4. awk learning summary awk is "processing by behavior Unit", while "processing by field as the smallest unit ". The variable name represents the meaning of NF. The total number of fields owned by each row ($0) NR currently processes the "row number" Data FS delimiter, the default value is the Space key. You can use the BEGIN keyword to preset awk variables, such as cat/etc/passwd | awk 'in in {FS = ": "} $3 <10 {print $1" \ t "$3} 'Description: all operations on {}. If you need multiple commands, use semicolons (;) to separate them, alternatively, press the [enter] button to separate each command. 5. trace and debug Shell scripts sh [-nvx] scripts. sh-n does not execute the script. Only query syntax.-v first outputs the script content to the screen before executing the script.-x displays the script content on the screen, easy to debug
Author hopezhangbo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.