1. About single quotes, double quotes, reverse single quotes features
`` # Reverse single quotes, can identify the commands and variables inside, and execute the commands inside first, the result after the command execution is completed, it is referenced by another command
Features: Both commands and variables can be identified
Usage: It is often used when a command calls another command to execute the result
echo `echo $PATH`
"" # Double quotes can identify commands, not variables
'' # Single quotes, variables and commands are not recognized
$() = ``
2.tab # Complete the path or command or file name
3. .bash_history # record history execution command
history # See the history command executed just now, and each command has a mark in front of it, you can! mark, you can call this command
skills:
Repeat the previous command using the up arrow key and press enter to execute = press !!
! -1 # Execute the last to last command
! ps # Repeat the previous command starting with "ps"
!? ps # Repeat the previous command containing ps
! ps: p # Print command history only, not execute
^ ps ^ ls # Replace the first ps in the previous command with ls
ctrl-r # to search the command in the command history, after the search, execute directly
Ctrl + g # Exit from the historical search mode
To recall the last parameter in the previous command
! $ # Means
Expand knowledge:
command! ^ Use the first parameter of the previous command as the parameter of cmd
command! $ Use the last parameter of the previous command as the parameter of cmd
command! * Use all the parameters of the previous command as cmd parameters
command!: n Use the nth parameter of the previous command as the parameter of cmd
command! n: ^ call the first parameter of the nth command
command! n: $ calls the last parameter of the nth command
command! n: m calls the mth parameter of the nth command
command! n: * call all parameters of the nth command
4. Detailed history (1000 records by default)
history -c # clear history command in memory
history -d 36 # Clear the specified line
history -n 10 # Clear the last 10 lines
history -w /1.sh # Save the history list to the specified history file
5. Command history related environment variables
HISTSIZE: number of command history records
~ / .bash_history # The default history file
HISTTIMEFORMAT = "% F% T" # display time
/ etc / profile or ~ / .bash_profile # permanently save
HISTIGNORE = "str1: str2 *:…" # Ignore the history of str2, the beginning of str2
HISTIGNORE environmental usage
ignoredups By default, repeated commands are ignored, continuous and the same is "repeat"
ignorespace Ignore all commands starting with white space
ignoreboth is equivalent to ignoredups, ignorespace combination
erasedups delete duplicate command (regardless of whether it is continuous with the previous one, as long as there is a duplicate, it will be deleted)
Permanently save:
export variable name = "value"
Store in / etc / profile or ~ / .bash_profile
6. Shortcut keys
Ctrl + l to clear the screen, equivalent to the clear command
Ctrl + o execute the current command and redisplay the command
Ctrl + s block screen output, lock
Ctrl + q allows screen output
Ctrl + c terminate command
Ctrl + z suspend command
Ctrl + a Move the cursor to the beginning of the command line, equivalent to Home
Ctrl + e Move the cursor to the end of the command line, equivalent to End
Alt + f Move the cursor one word to the right
Alt + b Move the cursor one word to the left
Ctrl + xx cursor moves between the first command line and the cursor
Ctrl + u delete from the cursor to the beginning of the command line
Ctrl + k Delete from the cursor to the end of the command line
Alt + r delete the current entire line
Ctrl + w Delete from the cursor to the left to the beginning of the word
Alt + d Delete right from the cursor to the end of the word
Ctrl + d Delete a character at the cursor
Note: Alt shortcut keys often conflict with other software