[Study Notes-Linux] understanding and learning bash

Source: Internet
Author: User
Understanding and learning bashtable OF CONTENTS
    • 1. Understand bash
    • 2. Shell Variable Functions
    • 3. Command alias and History commands
    • 4. bash shell operating environment
    • 5 Data Stream redirection
    • 6 pipeline commands
1 Understanding bash
    • Use shell to communicate the input commands with the kernel so that the kernel can control the hardware work.
    • ViewShell: Cat/Etc/Shell
      • The default shell type is recorded in/etc/passwd after logon, which is related to the account.
    • Command alias: alias LM = 'LS-al' # Note whether there are spaces
    • Help: Man bash
    • Command type: Type
      • Type LS # ls is aliased to 'LS-color = auto'
      • Type cat # Cat is hashed (/bin/CAT)
      • Type CD # CD is a shell builtin
    • Command Execution:
      • \ [Enter]: escape [enter]. Do not execute after pressing, but start another line.
2 Shell Variable Function
    • Concept: different users can have different values for the same variable. Therefore, variables can be used to represent the value without writing specific values.Program, Such as $ path
    • DISPLAY variable: Echo $ path
    • Set variable: Path = xxx # Note whether there are spaces
    • Expanded variable: Path = $ path: XXX
    • Cancel variable: unset mail
    • View environment variables: ENV
    • View environment variables and custom variables: Set
      • PS1: prompt character settings
    • Custom variable to environment variable: Export
      • Why should we convert it to an environment variable? Because the subroutine inherits the environment variable of the parent program.
    • Supported languages
      • View supported languages: locale-
      • View the variables related to the language family: locale
    • The keyboard reads user input read: Read atest # reads user input into the atest variable
    • Declare the variable type declare: declare-I sum = 100 + 50
3 Command alias and History commands
    • Alias

      • Alias LM = 'LS-Al | more'
      • Unalias LM
    • History commands
      • History
4 BASH Shell operating environment
    • Query order during Command Execution

      • Relative/absolute path-> alias-> bash built-in-> $ path
    • Bash configuration file
      • Login Shell/non-Login Shell

        • Login Shell: Enter the account and password when entering the shell.
        • Non-login shell: you can log on through the GUI. You do not need to enter the account password when starting the shell again.
      • Configuration File
        • Login Shell:

          • /Etc/profile: overall system settings
          • The following three files are read in order. If they exist, they will not be read.
          • ~ /. Bash_profile
          • ~ /. Bash_login
          • ~ /. Profile
      • Wildcard
        • *: 0 to infinite characters
        • ? : One character
        • []: [ABC] # A or B or C
        • [-]: [0-9] #0 to 9
        • [^]: [^ ABC] # It is not a character of A, B, and C.
5 Data Stream redirection
    • >: Overwrite
    • >>: Accumulate
    • /Dev/null: receive information but not show
    • Run the following commands in sequence: cmd1, cmd2, and cmd3.
    • Determine the next one based on the previous execution result
      • Cmd1 & cmd2
      • Cmd1 | cmd2
6 Pipeline commands
    • Ls | less
    • Cut: Split data in the same row
      • Echo $ PATH | cut-d': '-F 5 # split by': ', 5th pieces of data
    • Grep: If a row contains the required information, this row is returned.
    • Sort: Sorting
    • Uniq: duplicate content is displayed only once.
    • WC: count words
    • Tee: bidirectional redirection
    • TR: delete or replace Data
    • Col: Convert to plain text
    • Join: Put the relevant information in the two files together
    • Paste: combine the two rows and separate them with [Tab ].
    • Expand: Convert [Tab] to Space
    • Split: transfers large files to small files.

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.