5.2 Bash Variables
The following variables are set or used in Bash. Other shells generally do not process these variables.
Some variables used by Bash are also described in other chapters: for example, for variables used by tools for controlling jobs, see 'job control variable '.
BASH
Execute the full path name of the current Bash instance.
Basw.ts
List of enabled shell options separated by colons. Each word in the list is a valid parameter of the built-in command
built-in command set (see the "Set built-in command" section) can be used as an option when shell is called. In addition, you can use multiple character options. To be recognized, these options must be placed before a single character option in the command line.
-- Debugger
Specify the configuration file for the debugger before starting the shell. Open the extended debugging mode (see the extdebug option of the shopt built-in command in
# shopt-s Extglob# RM-FR! (File1)If you have multiple exclusions, you can do this:# RM-RF! (File1|file2)First Shopt-s Extglob under the popular scienceThe Bash Shell has a extglob option that allows the shell to identify 5 additional pattern matching operators, which makes it easier to match files.The Open method is simple, using the shopt command:
group of parameters as a separate group.
"$ @" Is always separated by spaces and parameters are considered as separate items, even if they are enclosed in double quotation marks. "$ @" Is usually used to transmit the entire set of switches to another command (for example, ls $ @).
Although positioning parameters are a simple method to traverse switches and parameters, they do not always traverse the parameter list directly in this way. There is a built-in command shift, it can discard the p
Backup of bashrc in ubuntu13.04 #~ /. Bashrc: executedbybash (1) fornon-loginshells. # see/usr/share/doc/bash/examples/startup-files (inthepackagebash-doc) # backup of bashrc for forexam ubuntu 13.04 #~ /. Bashrc: executed by bash (1) for non-login shells. # see/usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples # If not running interactively, don't do anything case $-in * I *); *) return; esac # don't put duplicate lines or lines starting with space in the histor
Backup of bashrc in ubuntu 13.04 #~ /. Bashrc: executed by bash (1) for non-login shells. # see/usr/share/doc/bash/examples/startup-files (in the package bash-doc) # for examples # If not running interactively, don't do anything case $-in * I *); *) return; esac # don't put duplicate lines or lines starting with space in the history. # See bash (1) for more options HISTCONTROL = ignoreboth # append to the history file, don't overwrite It shopt-s hista
BASH Shell has an extglob option. After the shell is enabled, five pattern matching operators can be identified to facilitate file matching.
Method:
Run shopt command: shopt-s extglob
Close method: shopt-u extglob
When this feature is enabled, the following five pattern matching operators are recognized:
? (Pattern-list)-the given pattern matches 0 times or
In linux, the set command, which is commonly used but not easy to remember, can be used to customize the shell environment and enable or disable the option using option o. For example, enable option: set-o option, and disable option: set + o. The shopt command is an alternative to the set command... in linux, the set command, which is commonly used but not easy to remember, can be used to customize the shell environment. the option "o" is used to enab
1. grepWhen using grep, you should first look at the current file or folder, get the text or file name in the existing file, and then use the grep command1 Less Os.fa | grep -v >os > File223"2, RMRM deletes files other than the specified file and needs to be used! To do non-matching. However, this requires that the EXTGLOB option be turned on and the shell can identify 5 additional pattern matching operators to make file matching easier.Use the shopt
you think it is, it simply removes hard links to the data on the file system and hard disk. The data on the hard disk still exists until overwritten by another app rewrite. For very sensitive data, this poses a big security risk.The Shred command is an upgraded version of the RM command. When you use the Shred command to delete a file, the data in the file is repeated randomly. There is even an option to clear all data after a random overwrite.If you want to safely delete a file and overwrite i
array at a time, using the followingRead-a Arr Option-A is to specify ARR as an array variable.Extract array element value method:echo ${arr[n]} N starting from 0Shopt.Purpose: Displays and sets the shell's behavior options to enhance the shell's ease of use.Usage: shoptCase:4 shopt–p or ShoptExecution result: Show all shell action options that can be set4 shopt–s MailwarnExecution result: Enable message a
, mailpath, and mailcheck variables (see the bash Variable Section ).14. After 'set-U' is enabled, the shell will not exit due to an extension error that occurs due to reference to the unbound shell variable. (See the "set built-in commands" section)15. At $ {var :? In word}, the shell does not exit because VaR is not set or the value is null. (See the shell parameter expression Section)16. The redirection error caused by Shell built-in commands will not cause shell exit.17. When running in POSI
ignoreeof, and set-O ignoreeof. I think there are a lot of such environment-set parameters, but they are rarely used. You can use man set to determine if you need them. In addition, noclobber is commonly used. You cannot rewrite an existing file by> redirection. In bash 2.0, shopt is provided for setting, and unset is also provided. However, I do not think it is necessary to remember this and it is rarely used in practical applications. This is not r
# Aliases are not expanded when the shell is not interactive, unless # + Expand_aliases shell option is set using shopt Shopt - S expand_aliases Case "$1" In"Debug")Alias mydebug='Echo-N $ (caller 0 | TR "": "): $ funcname: $ lineno: Log :""';;;*)Alias mydebug='';;;Esac
Test:
#! /Bin/bash # mydebug_test.sh source / etc / mydebug debug; # If a parameter is included in deb
1. Open the/ETC/BASH.BASHRC file with the VI editor (requires root permission)sudo vi/etc/bash.bashrcNext, you'll be prompted for a passwordAt this point vi may appear up and down problems, the solution:(1) Execute command sudo apt-get remove Vim-common(2) Execute command sudo apt-get install vim2. Locate the following code in the file#enable Bash completion in interactive shells#if! Shopt-oq POSIX; Then# if [-f/usr/share/bash-completion/bash_completi
$-inch*i*) ;; *)return;; esac# Don'T put duplicate lines or lines starting with space in the history.# See Bash (1) forMore Optionshistcontrol=ignoreboth# Append to the history file, Don'T overwrite itShopt-s histappend# forSetting history length See Histsize and HistfilesizeinchBash1) Histsize= +histfilesize= -# Check the window size after each command and,ifnecessary,# Update the values of LINES and columns.shopt-s checkwinsize# IfSet, the pattern"**"Usedincha pathname expansion context will#
enabled In/et C/BASH.BASHRC and/etc/profile# SOURCES/ETC/BASH.BASHRC). If [-f/etc/bash_completion] ! Shopt-oq POSIX; Then. /etc/bash_completionfi3./ETC/BASH.BASHRC# system-wide. bashrc file for interactive bash (1) shells.# to enable the settings/commands in this file for login shell s as well,# this file have to is sourced in/etc/profile.# If not running interactively, don ' t do anything[-Z "$PS 1"] am p; return# Check the window size after each co
the history command, not inside the. bash_history fileHistsize defines the maximum number of stored commands,Hisfilesize defines the maximum history file size,The Histcontrol definition ignores leading spaces,Histingore defines a command that does not need to be stored, where ignoredups ignores duplicate rows, Ignorespace ignores lines with leading spaces, Ignoreboth ignores bothHistfile Defining History filesShell all parameters $* [email protected] the latter is separate, remember to use doub
file does not exist, 127 is returned.10. Execution Environment of the command (0.5), (Kw:command execution Environment)1. Open the file2. Current working directory3. Umask4. Signal Trap--process communication5. Shell variables6. Shell functions7. Shell's function options (set, shopt) Set-o Vim/emacs8. Shell Name9. Various process IDs ($$, $PPID)11. Environment variables (0.5), (kw:environment)When a command is executed, a string array (list) is passe
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.