Shell learning notes (1) key concepts and commands in shell

Source: Internet
Author: User
Tags month name

Shell learning notes (1) key concepts and commands in shell
Variable variableName = value

  1. There cannot be spaces around the equal sign
  2. The variable content must be enclosed by space, but v = "hello $ name" $ does not support the original function. It cannot be enclosed in single quotes. v = "hello '$ name'" is plain text.
  3. Escape Character \ converts special characters into common text 'COMMAND ', $ (command), and provides Command Execution information in the text
  4. Variable accumulation, name = xiaoyi; name = $ name: 'Welcome to hz'
  5. The child process can inherit the environment variables of the parent process but cannot inherit the custom variables of the parent process. The export variable name converts the custom variables into environment variables.
    Read data from the keyboard: read-p' prompt '-t num v # num time, v variable name array declaration and use: v [1] = 'hello '; v [2] = 'xiao' echo $ {v [1]}

    Path and command query order
    1. Execute commands in relative/absolute paths, such as/bin/ls
    2. This command is found by alias for execution.
    3. Executed by bash built-in commands
    4. Run the first command in the order of $ PATH.

      The command source for reading the shell configuration file is a point ., because. bashrc can only be read during login. If the modification takes effect immediately, we need to call the source command to read the modified configuration file. For example: source ~ /. Bashrc equals .~ /. Bashrc
      Pipeline command scenario: when the data needs to be processed several times before reaching the desired format, the first data in the pipeline must be able to accept the standard input command.
      Select command: cut, grep
      • Cut is segmented by the unit of action. cut-d 'delimiter '-f fields is mainly used for split display of row data.
        Cut-c character range
        Eg:
        Echo $ PATH | cut-d': '-f 5 // select the fifth path in the PATH separated:
        • Grepgrep analyzes the data we want in a row of information.
          Grep [-acinv] [-- color = auto] 'query string' filename
          -A searches binary files for data in text format.
          -C: count the number of matched data
          -I case-insensitive
          -N: Output row number
          -V output the grep line without matching content can be used in combination with regular expression
          Command for sorting and statistics: sort, wc, uniq
          • Sort
            Sort [-fbMnrtuk] [file or stdin]
            -F case-insensitive
            -B. Ignore the leading space.
            -M is sorted by month name.
            -N: use pure numbers for sorting
            -R reverse sorting
            -Only one data item with the same u
            -T Separator
            -K is sorted by that interval
            Eg:
            Cat/etc/passwd | sort-t': '-k 1 // sort by the first column: Split

          • Wc statistical word, line or Character Count
            Wc [-lwm]
            -L number of rows
            -W words
            -M characters
            Eg:
            Cat/etc/profile | wc-lwm
            • The duplicate uniq data appears once.
              Uniq [-ic]
              -I case-insensitive
              -C for counting
              Eg:
              Last | cut-d ''-f1 | grep '^ xiaoyi' | uniq-c

              Character conversion command tr, col, join, paste, expand
              • Tr: tr [-ds] set1
                -D: Delete the set1 field in the information.
                -S replaces repeated characters
                Eg: lowercase for last | tr 'a-z'' a-Z'

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



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.