Linux Learning notes Chapter 8th Linux Shell Basics

Source: Internet
Author: User
Tags aliases

Tagged with: Linux centos Shell wildcard

8.1shell Introduction
The shell is a command interpreter that provides human-computer interaction.
Supports specific syntax.
Each user can have their own specific shell (bash).
CentOS7 default bash (Bourne Agin Shell).
Others are zsh, ksh and so on.

8.2 Command History
The command history is stored under the ~/.bash_history file.
History View the previously used commands, save the last 1000 by default, the variable histsize set the number of bars, histsize can be configured in the configuration file/etc/profile, the configuration requires source to take effect.
history-c Clears the current in-memory command history and cannot clear commands in ~/.bash_history.
The current command, which is stored in memory, is saved to the. bash_history file when you exit the terminal.
The histtimeformat= "%y/%m/%d%h:%m:%s" setting displays the time format, which can be configured permanently in/etc/profile. Once configured, history Displays the time the command was executed.
chattr +a ~/.bashhistory plus a permission, can only append, cannot delete, make the command history permanent save.
If you do not exit the terminal properly, there will be errors in the command history save.
!! Executes the previous command.
!n N is a number that executes the nth command in the command history.
!word Executes the most recent command that begins with Word.

8.3 Command Completion and aliases
tab , tap (the only auto-complete), double-tap (multiple list).
CENTOS7 supports auto-complete command parameters. You need to install the package:yum install-y bash-completion, and then reboot Restart the system before it takes effect.
Command aliases alias command= ' comand blablabla '
alias to view command aliases in the system.
The command aliases can be configured in files in the ~/.BASHRC and/etc/profile.d/directories.
unalias Command cancels the custom command command alias.

8.4 Wildcard Characters

    • Matches any number of any character.
      ? Matches an arbitrary character.
      [0-3] or [0123] matches any one of the characters in the square brackets. [0-9a-za-z]
      {1,2,3,a} matches any one of the curly braces.

8.5 Input and output redirection
\> output redirection.
command >file writes the command's correct output to FILE.
command >>file appends the command's correct output to FILE.
command 2>file writes the error message of the command run output to FILE.
command 2>>file appends the command run output error message to FILE.
Correct + error:>+2> with &>.
command &>file writes the correct and error messages for the command run output to FILE, and also supports the Append command &>>file.
command >file1 2>file2 can save the correct and wrong information separately and is used for writing shell scripts. Such as:
LS 1.txt 2.txt >t.txt 2>e.txt
< input redirection (almost not available).
command <file to enter the file contents into the command commands. Such as:
wc-l <1.txt View the number of lines of content in 1.txt.
wc-l >1.txt is the correct output of wc-l , written in 1.txt.

Linux Learning notes Chapter 8th Linux Shell Basics

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.