Bird Book Shell Learning Notes (i) Key concepts and commands in the shell

Source: Internet
Author: User
Tags month name

Variable Variablename=value
    1. Cannot have spaces around equals sign
    2. Variable content has a space to use "or", but v= "Hello $name" $ to maintain the original function, single quotation marks do not, v= "Hello ' $name '" plain text
    3. Use escape character \ Convert special characters to normal text ' command ', $ (command), provide command execution information in text
    4. variable accumulation, name=xiaoyi; Name= $name: ' Welcome to Hz '
    5. The child process can inherit the environment variable of the parent process but cannot inherit the custom variable of the parent process, export variable name; Change the custom variable to an environment variable

Read the data from the keyboard: Read-p '-t ' to Num v # num time, v variable an array group declaration and use: v[1]= ' hello '; v[2]= ' Xiao ' echo ${v[1]}

Path and command Lookup order
    1. Execute commands with relative/absolute paths, such as/bin/ls
    2. This command is found by alias to execute
    3. Executed by bash built-in commands
    4. Find the first command to execute by $path the order of this variable


The command to read the shell configuration file is either a point or a dot. , because. BASHRC can only be read at the time of landing, and if it is modified to take effect immediately, we need to call the source command to read the current modified corresponding configuration file Eg:source ~/.BASHRC equals. ~/.bashrc
Pipeline Command scenario: When the data needs to be processed several times before the pipeline comes to the format we want, the first data must be a command that accepts standard input.
Pick Command: Cut,grep
    • Cut
Cut by the Unit of Action cut-d ' break character '-f fields, mainly for split display of row data
Cut-c Character Range
eg
echo $PATH | Cut-d ': '-F 5//select path to: Split fifth
    • Grep
grep analyzes the data we want in a line of information
grep [-ACINV] [--color=auto] ' Find string ' filename
-A binary file looks up data in text mode
-C Statistics match to the number of data
-I ignores case
-N Output line number
-V outputs a row with no matching content grep can be used in conjunction with regular expressions
Sort and Statistics commands sort, WC, uniq
  • Sort
    sort [-fbmnrtuk] [file or stdin]
    -F ignores case
    -B ignores the front space
    -m sort by month name
    -N using pure numeric sorting
    -R Reverse Sort
    -U The same data item appears only one item
    -T delimiter
    -K to sort by that interval
    eg
    cat/etc/passwd | Sort-t ': '-K 1//pair to: Sort the first column of the split

  • WC statistic Word, line or character number
    WC [-LWM]
    -L Number of rows
    -W Words
    -M character Count
    eg
    Cat/etc/profile | Wc-lwm
    • Uniq duplicate data appears once
      Uniq [-ic]
      -I ignores case
      -C to Count
      eg
      Last | Cut-d '-f1 | grep ' ^xiaoyi ' | Uniq-c

Character Conversion Instructions TR, col, join, Paste, expand
    • TR:TR [-ds] Set1
      -D set1 field in delete message
      -S replaces duplicate characters
      Eg: lowercase for uppercase Last | Tr ' A-Z ' A-Z


Find./-name "*.java" | Xargs wc-l
Find grep speaks the better link: http://www.cnblogs.com/skynet/archive/2010/12/25/1916873.html
Special symbols:



Bird Book Shell Learning Notes (i) Key concepts and commands in the shell

Related Article

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.