Bash (from the English B ourne a gain sh ell , pun "Born again" shell - "revived" shell) - an improved and modernized variation of the command shell Bourne shell . One of the most popular modern variations of the UNIX command shell. Especially popular in the Linux environment, where it is often used as a pre-installed shell.
| GNU Bourne-Again Shell | |
|---|---|
Typical Bash Session | |
| Type of | UNIX shell |
| Author | Brian Fox |
| Developer | Chet Ramey |
| Written on | Si |
| operating system | Unix-like |
| Interface languages | English , multilingual ( gettext ) |
| First edition | |
| Hardware platform | |
| Latest version | |
| Readable File Formats | |
| License | GNU General Public License |
| Website | gnu.org/software/bash/ |
It is a command processor that works, as a rule, interactively in a text window. Bash can also read commands from a file called a script (or script ). Like all Unix shells, it supports autocompletion of file and directory names, substitution of the output of command results, variables, control over the execution order, branch and loop operators. Keywords, syntax, and other basic language features were borrowed from sh . Other features, such as history, were copied from csh and ksh . Bash basically complies with the POSIX standard, but with a number of extensions [2] .
The name "bash" is an acronym for English. Bourne-again-shell ("another-command-shell-Bourne") and is a pun: Bourne-shell - one of the popular varieties of the command shell for UNIX (sh), authored by Stephen Bourne ( 1978 ), improved in 1987 by Brian Fox . The surname Bourne (Bourne) has something in common with the English word born , meaning "born", hence: born-again-command shell.
In September 2014, a widely exploited Bashdoor vulnerability was discovered in bash.
Syntax Differences
The vast majority of important Bourne shell scripts can be run unchanged in bash, with the exception of those that refer to special Bourne variables or use the Bourne built-in commands. The Bash command syntax includes ideas borrowed from Korn shell ( ksh ) and C shell ( csh ), such as command line editing, command history, directory stack, $RANDOM and $PPID , $(β¦) command replacement syntax. When Bash is used as an interactive command processor, it supports the completion of program names, files, variables, etc. using the Tab βΉ key.
Internal Commands
The bash interpreter has many built-in commands, some of which have similar executable files in the operating system. However, it should be noted that most often there are no man pages for built-in commands, and when you try to view help on a built-in command, the help on the executable file will actually be issued. The executable file and the built-in command may differ in parameters. Information on built-in commands is described in the bash man page:
man bash
| Input Output | |
|---|---|
echo | displays the expression or contents of a variable ( stdout ), but has limitations in use [3] |
printf | formatted output command, extended echo command |
read | "Reads" the value of a variable from standard input ( stdin ), in interactive mode it is a keyboard |
| File system | |
cd | changes the current directory |
pwd | displays the name of the current working directory (from the English print working directory ) |
pushd | changes the current directory with the ability to return in the reverse order |
popd | returns current directory after pushd |
dirs | list or clear the contents of the directory stack stored via pushd |
| Actions on Variables | |
let | performs arithmetic operations on variables |
eval | translates a list of arguments from a list to commands |
set | changes the values ββof internal script variables |
unset | deletes a variable |
export | exports a variable, making it available to child processes |
declare , typeset | set and / or impose constraints on variables |
getopts | used to parse the arguments passed to the script from the command line |
| Script management | |
source (point) | running the specified script |
exit | script shutdown |
exec | replaces the current process with a new exec command |
shopt | allows you to change the keys (options) of the shell on the fly |
| Teams | |
true | returns completion code zero (success) |
false | returns a completion code that indicates failure |
type prog | prints the full path to prog |
hash prog | remembers the path to prog |
help COMMAND | displays a brief reference on using the internal command COMMAND |
| Management of tasks launched in the command shell | |
jobs | shows a list of tasks launched in the command shell, or information about a specific task by its number |
fg | switches the input stream to the current task (or to a specific task, if its number is specified) and continues its execution |
bg | continues to execute the currently paused task (or certain tasks, if their numbers are indicated) in the background |
wait | awaits completion of specified tasks |
Scripts
In the simplest case, a script is a simple list of commands written to a file. The command processor should know that it should process this file, and not just read its contents. A special construct called shebang serves for this: #! . The # character specifies a comment, but in this case shebang means that after this special character there is a path to the interpreter for script execution.
Syntax
The syntax for bash commands is the extended syntax for Bourne shell commands. The final bash command syntax specification is in the Bash Reference Manual distributed by the GNU project. [four]
"Hello world"
#! / usr / bin / env bash
echo 'Hello World!'
This script contains only two lines. The first line tells the system which program is used to run the file. The second line is the only action that this script executes; it actually prints βHello world!β In the terminal.
Run Script
In order for the script to become executable, the following commands can be used:
chmod + rx scriptname # granting read / execute rights to any user
chmod u + rx scriptname # granting rights to read / execute only to the "owner" of the script
For security reasons, the path to the current directory . not included in the $PATH environment variable. Therefore, to run the script, you must explicitly specify the path to the current directory in which the script is located:
./scriptname
In addition, you can pass such a file for execution to the Bash interpreter explicitly using the bash command:
bash scriptname
In this case, neither setting the access rights nor using the sequence #! is required #! in code.
I / O Redirection
There are built-in file descriptors in bash: 0 (stdin), 1 (stdout), 2 (stderr).
- stdin - standard input - what the user types in the console;
- stdout - standard output of the program;
- stderr - standard error output.
There are special characters for operations with these and user descriptors: > (output redirection), < (input redirection). Symbols & , - can precede the descriptor number; for example, 2>&1 - redirecting handle 2 (stderr) to handle 1 (stdout).
0<filename or <filename | Redirecting input from filename |
1>filename or >filename | Redirecting output to the file "filename". If the noclobber option is disabled, the file is overwritten with incoming data. |
1>|filename or >|filename | Redirecting output to the file βfilenameβ, the file is overwritten by the incoming data |
1>>filename or >>filename | Redirecting the output to the file "filename", the data is added to the end of the file. If there is no file, it is created. |
2>filename | Redirecting standard error output to the file "filename" |
2>>filename | Redirecting standard error output to the file "filename", data is added to the end of the file. If there is no file, it is created. |
&>filename | Redirecting output and errors to the file "filename" |
2>&1 | Redirecting error output to standard output |
Bash has an individual redirection syntax that is not supported in the Bourne shell. Example of simultaneously redirecting standard output and standard errors:
command & > file
This is easier to type than the equivalent command in the Bourne shell syntax.
command > file 2 > & 1
Redirect "from script code"
The heredoc syntax is supported:
- With the interpretation of variables and language constructs inside a block:
$ a = 'multi-line'
command << MYDOC123
$ a
text
$ (<$ HOME / my_file.txt)
MYDOC123
- Without interpretation of variables:
command << 'PERLCODE'
my $ first = 'Hello';
my $ second = 'world';
say join (',', $ first, $ second), '!';
PERLCODE
- With removal of initial indents (only indents are supported by tabs):
command << - 'TABSTRIP'
for ((i = 0; i <10; i ++))
do
echo "$ i"
done
TABSTRIP
Starting with version 2.05b, bash can redirect standard input from a string using the following here strings syntax:
command <<< "string to be read as standard input"
If a string contains spaces, it should be enclosed in quotation marks or apostrophes, or escape spaces with a backslash.
Be careful: the line you enter using here strings contains an implicit sequence to end the line: either 1 extra byte of line feed , or 2 extra bytes: carriage return and line feed.
cat - <<< '123' | wc -c
# Result: 4
cat < ( echo -n '123' ) | wc -c
# Result: 3
wc -c <<< '123'
# Result: 4
echo -n 123 | wc -c
# Result: 3
Starting with version 4.1 [5], it became possible to indicate a terminating sequence of characters in one line and, immediately after it, a bracket. This may be useful for assigning a here-doc content variable:
var = $ ( cat - << 'TERMSEQ'
February. Get ink and cry!
Write about feverishly about February,
While the rumbling slush
In spring it burns black.
TERMSEQ )
In this case, a BASH warning message will be generated.
Redirection for the whole process
Example (redirecting standard output to a file, writing data, closing a file, resetting stdout):
# make Filedescriptor (FD) 6 a copy of stdout (FD 1)
exec 6 > & 1
# open file "test.data" for writing
exec 1 > test.data
# produce some content
echo "data: data: data"
# close file "test.data"
exec 1 > & -
# make stdout a copy of FD 6 (reset stdout)
exec 1 > & 6
# close FD6
exec 6 > & -
Opening and closing files:
# open file test.data for reading
exec 6 <test.data
# read until end of file
while read -u 6 dta
do
echo " $ dta "
done
# close file test.data
exec 6 < & -
Command Substitution
Capturing the output of external commands:
# execute 'date' and put the result in VAR
VAR = " $ ( date ) "
echo " $ VAR " # will display the date at the time the previous line was called
At the same time, null-character strings are not supported, the final line feeds disappear, unlike channels and other file I / O.
Conditional Operator
#! / usr / bin / env bash
T1 = 'foo'
T2 = 'bar'
if [[ $ T1 == " $ T2 " ]]
then
echo 'condition is satisfied'
else
echo 'condition not fulfilled'
fi
Note that quotation marks around the left side are optional. [6]
Cycles
#! / usr / bin / env bash
for i in "Number" { 1 ..10 }
do
echo " $ i "
done
1 #! / Usr / bin / env bash
2 COUNTER = 0
3 while [[ $ COUNTER -lt 10 ]]
4 do
5 echo The counter is $ COUNTER
6 let COUNTER = COUNTER + 1
7 done
#! / usr / bin / env bash
i = 0
until [[ $ i -eq 10 ]]
do
echo " $ i "
i = $ (( $ i + 1 ))
done
#! / usr / bin / env bash
# inside double parentheses, variables can be written in C-style (without $ and separating operators and operands with a space)
for (( i = 0 ; i < 10 ; i ++ ))
do
echo -n " $ i ;"
done
Arrays
In bash, only one-dimensional arrays are implemented. Indexes can be either integer values ββ(an "ordinary" array ) or strings ( an associative array , or a "hash").
Despite the unification of the syntax for working with regular and associative arrays, the former are not a variation of the latter either from the point of view of the end user or from the point of view of the internal logic of the interpreter itself.
As a natural consequence of the support of "associative" keys, in bash there is an extremely limited ability to emulate multidimensional arrays.
General Operations
Get a string consisting of all [7] elements of the array, separated by a space.
values = " $ { arr [@] } "
Get a string with all [7] indexes or array keys, regardless of whether they are numeric or text:
keys = " $ { ! arr [@] } "
Carry out mass replacement of the first occurrence of the substring βMAYβ with βMARCHβ in all [7] elements of the array and return a string composed of the resulting elements of the array, separated by a space:
values = " $ { arr [@] / MAY / MARCH } "
The same, but in each [7] element of the array all occurrences of the substring βMAYβ will be replaced:
values = " $ { arr [@] // MAY / MARCH } "
Until now, not all the features declared in the documentation work correctly for arrays. For example:
[ -v 'array_name' ]
fails for an empty array. [8]
Indexed Array Operations
Bash has support for one-dimensional arrays. The elements of the array can be initialized as: my_array[xx] . You can also explicitly declare an array in a script using the declare directive:
declare -a my_array
You can access individual elements of the array using curly braces: "${my_array[xx]}" .
There are two ways to initialize an indexed array:
one)
Array = ( element1 element2 element3 )
2)
temp_array [ 0 ] = element1
temp_array [ 5 ] = element
temp_array [ 9 ] = elementN
Adding elements to the end of an indexed array:
declare -a arrAnimals
arrAnimals = ( dog elephant horse cow fox koala turtle )
# Output the contents of the array:
echo " $ { arrAnimals [@] } "
# At the end of the arrAnimals array, add a new element: "pig"
arrAnimals + = ( pig )
# And again, show the contents of the array:
echo " $ { arrAnimals [@] } "
Get the first element of the array:
echo " $ { arrAnimals [0] } "
Both indexed and associative arrays support the so-called βslicesβ:
# Another way to get the first element of an array
echo " $ { arrAnimals [@]: 0 : 1 } "
# Output 3 elements of the array, starting from the 2nd:
echo " $ { arrAnimals [@]: 2 : 3 } "
Note: in the case of associative arrays, the sequence of values ββin the general case will be random (determined by the hash function used), therefore, the operation of cutting on the associative array, although valid, has a very limited area of ββpractical application.
In arrays with numerical indices, βreverseβ (βnegativeβ) addressing is allowed, which allows access to elements starting from the end of the array:
# The value of the last element of the array
echo " $ { arrAnimals [-1] } "
# The value of the penultimate element of the array
echo " $ { arrAnimals [-2] } "
# ... etc.
Using the built-in mapfile (synonym: readarray ), you can map the contents of a text file to an indexed array:
declare -a fileWithLogins
mapfile fileWithLogins </ etc / passwd
for (( i = 0 ; i < $ {# fileWithLogins [@] } ; i ++ ))
do
echo "Line # $ i : $ { fileWithLogins [ $ i ] } "
done
Associative Array Operations
Starting with version 4.0, bash introduced support for associative arrays (the so-called hash arrays).
To declare associative arrays, use the -A switch of the declare built-in command:
declare -A hshArray
As with indexed arrays, two different syntaxes can be used to populate associative arrays:
one)
TheCapitalOf [ Georgia ] = 'Tbilisi'
TheCapitalOf [ Australia ] = 'Canberra'
TheCapitalOf [ Pakistan ] = 'Islamabad'
2)
TheCapitalOf = ([ Georgia ] = 'Tbilisi' [ Australia ] = 'Canberra' [ Pakistan ] = 'Islamabad' )
Using associative arrays you can simulate support for multidimensional arrays:
declare -A a # declares an associative array 'a'
i = 1 ; j = 2 # initialize multiple indexes
a [ $ i , $ j ] = 5 # assigning the value β5β to the cell β$ i, $ jβ (ie β1,2β)
echo $ { a [ $ i , $ j ] } # output stored values ββfrom "$ i, $ j"
Unfortunately, in current versions of bash, copying the contents of one associative array into another is not possible with a simple assignment. This problem can only be circumvented, for which there are two fundamentally different approaches:
1) Emulate the declaration of the second hash βfrom scratchβ by copying the declaration of the first hash:
declare -A hsh1
hsh1 = ( ... )
source < ( declare -p hsh1 | sed 's / ^ declare -A hsh1 / declare -A hsh2 /' )
2) Iterate over all [7] elements of the source hash and copy them to the target hash:
declare -A hsh1 hsh2
hsh1 = ( ... )
for k in " $ { ! hsh1 [@] } "
do
hsh2 [ " $ k " ] = " $ { hsh1 [ " $ k " ] } "
done
Safe work with arrays
Arrays are a convenient way to pass dynamically generated arguments to functions or commands. In addition, each element of the array is a separate argument.
args = ( -l -a / )
ls " $ { args [@] } " # ls -l -a /
ls $ { args [@] } # ls -l -a /
ls $ { args [*] } # ls -l -a /
However, when using arrays in this way, you should be careful because of the features of expanding arrays when using the special characters @ and * as indices.
If the array is enclosed in quotation marks and expanded using the @ index, a string of words is formed, where each word is a separate element of the array. However, if you do not enclose the expansion of the array in double quotation marks, then you may get a completely different result: the spaces that make up the array elements become word delimiters.
args = ( -l -a '/ home / user / Desktop' )
ls " $ { args [@] } " # view the contents of the directory '/ home / user / Desktop'
ls $ { args [@] } # error: the directories '/ home / user / Worker' and './table' do not exist
An array with index * enclosed in double quotation marks is expanded on one line, connecting all elements of the array through the delimiters stored in the IFS variable. If you do not specify double quotation marks, then the array is expanded similarly to expansion when using the @ index.
args = ( '' usr local bin )
IFS = '/' ls " $ { args [*] } " # view the contents of the directory '/ usr / local / bin'
IFS = '/' ls $ { args [*] } # alternately viewing the contents of the directories '.', './Usr', './local' and './bin'
When creating an array from the contents of a text variable, you must consider the possible presence of spaces in the text. For example, as one of the ways to create an array from an enumerated string, you can consider replacing the separator character with a space. However, the presence of gaps in shared elements will lead to fragmentation of the elements themselves into parts.
array = ( $ { text //, / } ) # wrong: the text in the variable 'text' could contain whitespace
IFS = ',' array = ( $ text ) # right: the separator character is a comma.
IFS = ',' read -r -a array <<< " $ text " # is correct (alternative with redirecting the contents of the variable 'text' to the command 'read')
Errors can be caused by creating an array from text received as a command output or from a file, since not only line breaks, but also spaces with tabs will be considered delimiters by default [9] .
array = ( " $ ( ls ) " ) # wrong: spaces in the file name can split the file name into two array elements
IFS = $ '\ n' array = ( " $ ( ls ) " ) # right: only line breaks will be a delimiter
mapfile -t array << ( ls ) # correct: alternative via the built-in mapfile command
Conveyor
The conveyor transfers the output of the previous command to the input of the next or to the input of the shell. The method is often used to link a sequence of commands into a single chain. The conveyor is indicated by | .
Example (grep works like a filter for standard output):
cat filename | grep pattern
Logical operations
Logical OR is denoted as || . In condition checking operations, the operator || returns 0 (success) if one of the operands is true (TRUE).
Logical AND is denoted as && . In condition checking operations, the && operator returns 0 (success) if and only if both operands are true (TRUE).
ΠΡΠΈΠΌΠ΅ΡΠ°Π½ΠΈΠ΅: ΠΠΎΠ·ΠΌΠΎΠΆΠ½Π°Ρ ΠΏΡΡΠ°Π½ΠΈΡΠ° Π² ΠΏΠΎΠ½ΠΈΠΌΠ°Π½ΠΈΠΈ Π²ΠΎΠ·Π½ΠΈΠΊΠ°Π΅Ρ ΠΈΠ·-Π·Π° ΡΠΎΠ³ΠΎ, ΡΡΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Π° true (ΠΈ ΡΡΠΏΠ΅ΡΠ½ΠΎΠ΅ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΠ΅ Π»ΡΠ±ΠΎΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Ρ) Π·Π°Π²Π΅ΡΡΠ°Π΅ΡΡΡ Ρ ΠΊΠΎΠ΄ΠΎΠΌ Π²ΠΎΠ·Π²ΡΠ°ΡΠ° 0, success ( false , Π½Π°ΠΎΠ±ΠΎΡΠΎΡ, Π½Π΅ 0), Π² ΡΠΎ Π²ΡΠ΅ΠΌΡ ΠΊΠ°ΠΊ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΎΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ true/false β ΠΎΡΠ»ΠΈΡΠ½ΠΎ ΠΎΡ Π½ΡΠ»Ρ/ΡΠ°Π²Π½ΠΎ Π½ΡΠ»Ρ.
Examples:
if false ; then echo "successfully" ; else echo "unsuccessfully" ; fi
unsuccessfully
let "a=(( 1 && 0 && 123))" ; echo $? ; echo $a
1 # ΠΠΎΠ΄ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ
0 # ΠΠ½Π°ΡΠ΅Π½ΠΈΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ "a", ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΎΠΉ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ
if (( 1 && 0 && 123 )) ; then echo "true" ; else echo "false" ; fi
false
let "a=(( 1 && 123 && -345 ))" ; echo $? ; echo $a
0 # ΠΠΎΠ΄ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ
1 # ΠΠ½Π°ΡΠ΅Π½ΠΈΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ "a", ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΎΠΉ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΈ
if (( 1 && 123 & -345 )) ; then echo "true" ; else echo "false" ; fi
true
false && echo "Π£ΡΠΏΠ΅ΡΠ½ΠΎΠ΅ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΠ΅" || echo "ΠΠ΅ΡΡΠΏΠ΅ΡΠ½ΠΎΠ΅ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΠ΅"
ΠΠ΅ΡΡΠΏΠ΅ΡΠ½ΠΎΠ΅ Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΠ΅
Π¦Π΅Π»ΠΎΡΠΈΡΠ»Π΅Π½Π½Π°Ρ ΠΌΠ°ΡΠ΅ΠΌΠ°ΡΠΈΠΊΠ°
Bash ΠΌΠΎΠΆΠ΅Ρ Π²ΡΠΏΠΎΠ»Π½ΡΡΡ ΡΠ΅Π»ΠΎΡΠΈΡΠ»Π΅Π½Π½ΡΠ΅ Π²ΡΡΠΈΡΠ»Π΅Π½ΠΈΡ Π²Π½ΡΡΡΠΈ ΠΏΡΠΎΡΠ΅ΡΡΠ°, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ((β¦)) ΠΈ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ $((β¦)) [10] , ΠΊΠ°ΠΊ ΠΏΠΎΠΊΠ°Π·Π°Π½ΠΎ Π½ΠΈΠΆΠ΅:
VAR = 55 # Π£ΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΠΌ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ VAR, ΡΠ°Π²Π½ΠΎΠΉ 55
(( VAR = VAR + 1 )) # ΠΠΎΠ±Π°Π²Π»ΡΠ΅ΠΌ Π΅Π΄ΠΈΠ½ΠΈΡΡ ΠΊ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ VAR. ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° ΠΎΡΡΡΡΡΡΠ²ΠΈΠ΅ Π·Π½Π°ΠΊΠ° '$'
(( VAR += 1 )) # Π‘ΠΎΠΊΡΠ°ΡΡΠ½Π½Π°Ρ ΡΠΎΡΠΌΠ° Π·Π°ΠΏΠΈΡΠΈ ΠΈΠ½ΠΊΡΠ΅ΠΌΠ΅Π½ΡΠ°
(( ++VAR )) # ΠΡΡΠ³ΠΎΠΉ ΡΠΏΠΎΡΠΎΠ± ΡΠ²Π΅Π»ΠΈΡΠ΅Π½ΠΈΡ VAR Π½Π° Π΅Π΄ΠΈΠ½ΠΈΡΡ. ΠΡΠΏΠΎΠ»Π½ΡΠ΅Ρ ΠΏΡΠ΅ΡΠΈΠΊΡΠ½ΡΠΉ ΠΈΠ½ΠΊΡΠ΅ΠΌΠ΅Π½Ρ
(( VAR++ )) # ΠΡΡΠ³ΠΎΠΉ ΡΠΏΠΎΡΠΎΠ± ΡΠ²Π΅Π»ΠΈΡΠ΅Π½ΠΈΡ VAR Π½Π° Π΅Π΄ΠΈΠ½ΠΈΡΡ. ΠΡΠΏΠΎΠ»Π½ΡΠ΅Ρ ΠΏΠΎΡΡΡΠΈΠΊΡΠ½ΡΠΉ ΠΈΠ½ΠΊΡΠ΅ΠΌΠ΅Π½Ρ
echo $(( VAR * 22 )) # Π£ΠΌΠ½ΠΎΠΆΠ°Π΅ΠΌ VAR Π½Π° 22 ΠΈ ΠΏΠ΅ΡΠ΅Π΄Π°Π΅ΠΌ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ ΠΊΠΎΠΌΠ°Π½Π΄Π΅
echo $ [ VAR * 22 ] # Π£ΡΡΠ°ΡΠ΅Π²ΡΠΈΠΉ ΡΠΏΠΎΡΠΎΠ± ΡΠ΄Π΅Π»Π°ΡΡ ΡΠΎ ΠΆΠ΅
(( VAR <<3)) # ΠΠΎΠ±ΠΈΡΠΎΠ²ΡΠΉ ΡΠ΄Π²ΠΈΠ³ Π²Π»Π΅Π²ΠΎ (ΡΠΎ ΠΆΠ΅, ΡΡΠΎ VAR*8)
((VAR>>3 )) # ΠΠΎΠ±ΠΈΡΠΎΠ²ΡΠΉ ΡΠ΄Π²ΠΈΠ³ Π²ΠΏΡΠ°Π²ΠΎ (ΡΠΎ ΠΆΠ΅, ΡΡΠΎ VAR/8)
ΠΠΎΠΌΠ°Π½Π΄Π° ((β¦)) ΡΠ°ΠΊΠΆΠ΅ ΠΌΠΎΠΆΠ΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡΡΡ Π² ΡΡΠ»ΠΎΠ²Π½ΡΡ
ΡΡΠ²Π΅ΡΠΆΠ΄Π΅Π½ΠΈΡΡ
, ΡΠ°ΠΊ ΠΊΠ°ΠΊ Π΅Ρ ΠΈΡΡ
ΠΎΠ΄Π½ΡΠΉ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡ β ΡΡΠΎ 0 ΠΈΠ»ΠΈ 1, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΌΠΎΠ³ΡΡ ΠΈΠ½ΡΠ΅ΡΠΏΡΠ΅ΡΠΈΡΠΎΠ²Π°ΡΡΡΡ ΠΊΠ°ΠΊ true ΠΈΠ»ΠΈ false:
if (( VAR == Y * 3 + X * 2 ))
then
echo Yes
fi
(( Z > 23 )) && echo Yes
ΠΠΎΠΌΠ°Π½Π΄Π° ((β¦)) ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΡ ΡΡΠ°Π²Π½Π΅Π½ΠΈΡ: == != > < >= <= .
Bash Π½Π΅ ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ Π²ΡΡΠΈΡΠ»Π΅Π½ΠΈΡ Π²Π½ΡΡΡΠΈ ΠΏΡΠΎΡΠ΅ΡΡΠ° Ρ ΡΠΈΡΠ»Π°ΠΌΠΈ Ρ ΠΏΠ»Π°Π²Π°ΡΡΠ΅ΠΉ ΡΠΎΡΠΊΠΎΠΉ. Π’ΠΎΠ»ΡΠΊΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΡΠ΅ ΠΏΡΠΎΡΠ΅ΡΡΠΎΡΡ Unix Korn shell (Π²Π΅ΡΡΠΈΡ 1993 Π³ΠΎΠ΄Π° ) ΠΈ zsh (Π½Π°ΡΠΈΠ½Π°Ρ Ρ Π²Π΅ΡΡΠΈΠΈ 4.0) ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°ΡΡ ΡΡΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ.
Π‘ΠΏΠΈΡΠΎΠΊ ΠΌΠ°ΡΠ΅ΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΡ
ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΉ: + , - , * , / , ** (Π²ΠΎΠ·Π²Π΅Π΄Π΅Π½ΠΈΠ΅ Π² ΡΡΠ΅ΠΏΠ΅Π½Ρ), % (Π΄Π΅Π»Π΅Π½ΠΈΠ΅ ΠΏΠΎ ΠΌΠΎΠ΄ΡΠ»Ρ, ΠΎΡΡΠ°ΡΠΎΠΊ ΠΎΡ Π΄Π΅Π»Π΅Π½ΠΈΡ), let β ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΠΎΠΊΡΠ°ΡΠ΅Π½ΠΈΡ Π°ΡΠΈΡΠΌΠ΅ΡΠΈΡΠ΅ΡΠΊΠΈΡ
ΠΊΠΎΠΌΠ°Π½Π΄ (ΡΠΎΠΊΡΠ°ΡΠ°Ρ ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΡΡ
ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ
; Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ: a += b ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ a = a + b ΠΈ Ρ. ΠΏ.).
ΠΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅ ΠΈ Π°ΡΠ³ΡΠΌΠ΅Π½ΡΡ
ΠΡΠ³ΡΠΌΠ΅Π½ΡΡ:
$$ | pid ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ shell (ΡΠ°ΠΌΠΎΠ³ΠΎ ΠΏΡΠΎΡΠ΅ΡΡΠ°-ΡΡΠ΅Π½Π°ΡΠΈΡ) |
$! | pid ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅Π³ΠΎ ΠΏΡΠΎΡΠ΅ΡΡΠ° Π² ΡΠΎΠ½ΠΎΠ²ΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅ |
$? | ΠΊΠΎΠ΄ Π²ΠΎΠ·Π²ΡΠ°ΡΠ° ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅Π³ΠΎ ΠΏΡΠΎΡΠ΅ΡΡΠ° (ΡΡΠ½ΠΊΡΠΈΠΈ ΠΈΠ»ΠΈ ΡΠΊΡΠΈΠΏΡΠ°) |
$ x | Π³Π΄Π΅ x β Π½ΠΎΠΌΠ΅Ρ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠ°, ΠΏΠ΅ΡΠ΅Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΡΠΊΡΠΈΠΏΡΡ ( $1 , $2 ΠΈ Ρ. Π΄., $0 β ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠΉ Π·Π°ΠΏΡΡΠ΅Π½Π½ΡΠΉ ΡΠΊΡΠΈΠΏΡ) |
$# | ΠΊΠΎΠ»ΠΈΡΠ΅ΡΡΠ²ΠΎ Π°ΡΠ³ΡΠΌΠ΅Π½ΡΠΎΠ² ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ |
$* | Π²ΡΠ΅ [7] Π°ΡΠ³ΡΠΌΠ΅Π½ΡΡ Π² Π²ΠΈΠ΄Π΅ ΠΎΠ΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ (ΡΠ»ΠΎΠ²Π°) |
$@ | ΡΠΎ ΠΆΠ΅ ΡΠ°ΠΌΠΎΠ΅, ΡΡΠΎ ΠΈ $* , Π½ΠΎ ΠΏΡΠΈ ΡΡΠΎΠΌ ΠΊΠ°ΠΆΠ΄ΡΠΉ [7] ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»Π΅Π½ ΠΊΠ°ΠΊ ΠΎΡΠ΄Π΅Π»ΡΠ½Π°Ρ ΡΡΡΠΎΠΊΠ° (ΡΠ»ΠΎΠ²ΠΎ) |
$- | ΡΠΏΠΈΡΠΎΠΊ ΡΠ»Π°Π³ΠΎΠ², ΠΏΠ΅ΡΠ΅Π΄Π°Π½Π½ΡΡ ΡΡΠ΅Π½Π°ΡΠΈΡ |
$_ | ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠΉ Π°ΡΠ³ΡΠΌΠ΅Π½Ρ ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Ρ |
ΠΡΡΡΠΎΠ΅Π½Π½ΡΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΠ΅:
$BASH | ΠΏΡΡΡ ΠΊ ΠΈΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌΠΎΠΌΡ ΡΠ°ΠΉΠ»Ρ bash |
$BASH_VERSINFO[n] | ΠΌΠ°ΡΡΠΈΠ², ΡΠΎΡΡΠΎΡΡΠΈΠΉ ΠΈΠ· 6 ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ², ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠΈΠΉ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎ Π²Π΅ΡΡΠΈΠΈ bash |
$BASH_VERSION | Π²Π΅ΡΡΠΈΡ Bash, ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½Π½ΠΎΠ³ΠΎ Π² ΡΠΈΡΡΠ΅ΠΌΠ΅ |
$DIRSTACK | ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ Π²Π΅ΡΡΠΈΠ½Ρ ΡΡΠ΅ΠΊΠ° ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΎΠ² |
$EDITOR | Π·Π°Π΄Π°Π½Π½ΡΠΉ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ ΡΠ΅Π΄Π°ΠΊΡΠΎΡ |
$EUID | Β«ΡΡΡΠ΅ΠΊΡΠΈΠ²Π½ΡΠΉΒ» ΠΈΠ΄Π΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΈΠΎΠ½Π½ΡΠΉ Π½ΠΎΠΌΠ΅Ρ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ (Effective User ID) |
$FUNCNAME | ΠΈΠΌΡ ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΡΡΠ½ΠΊΡΠΈΠΈ |
$GLOBIGNORE | ΠΏΠ΅ΡΠ΅ΡΠ΅Π½Ρ ΡΠ°Π±Π»ΠΎΠ½Π½ΡΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ², ΠΊΠΎΡΠΎΡΡΠ΅ Π±ΡΠ΄ΡΡ ΠΏΡΠΎΠΈΠ³Π½ΠΎΡΠΈΡΠΎΠ²Π°Π½Ρ ΠΏΡΠΈ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠΈ ΠΏΠΎΠ΄ΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ ΠΈΠΌΡΠ½ ΡΠ°ΠΉΠ»ΠΎΠ² (globbing) |
$GROUPS | Π³ΡΡΠΏΠΏΡ, ΠΊ ΠΊΠΎΡΠΎΡΡΠΌ ΠΏΡΠΈΠ½Π°Π΄Π»Π΅ΠΆΠΈΡ ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ |
$HOME | Π΄ΠΎΠΌΠ°ΡΠ½ΠΈΠΉ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ |
$HOSTNAME | ΡΠ΅ΡΠ΅Π²ΠΎΠ΅ ΠΈΠΌΡ Ρ ΠΎΡΡΠ° |
$HOSTTYPE | ΡΠΈΠΏ ΠΌΠ°ΡΠΈΠ½Ρ (ΠΈΠ΄Π΅Π½ΡΠΈΡΠΈΡΠΈΡΡΠ΅Ρ Π°ΠΏΠΏΠ°ΡΠ°ΡΠ½ΡΡ Π°ΡΡ ΠΈΡΠ΅ΠΊΡΡΡΡ) |
$IFS | ΡΠ°Π·Π΄Π΅Π»ΠΈΡΠ΅Π»Ρ ΠΏΠΎΠ»Π΅ΠΉ Π²ΠΎ Π²Π²ΠΎΠ΄ΠΈΠΌΠΎΠΉ ΡΡΡΠΎΠΊΠ΅ |
$LC_COLLATE | Π·Π°Π΄Π°ΡΡ ΠΏΠΎΡΡΠ΄ΠΎΠΊ ΡΠΎΡΡΠΈΡΠΎΠ²ΠΊΠΈ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ², Π² ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡΡ ΠΏΠΎΠ΄ΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ ΠΈΠΌΡΠ½ ΡΠ°ΠΉΠ»ΠΎΠ² ΠΈ Π² ΠΏΠΎΠΈΡΠΊΠ΅ ΠΏΠΎ ΡΠ°Π±Π»ΠΎΠ½Ρ |
$LC_CTYPE | ΠΎΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅Ρ ΠΊΠΎΠ΄ΠΈΡΠΎΠ²ΠΊΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ² |
$LINENO | ΠΠΎΠΌΠ΅Ρ ΡΡΡΠΎΠΊΠΈ ΠΈΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌΠΎΠ³ΠΎ ΡΡΠ΅Π½Π°ΡΠΈΡ |
$MACHTYPE | Π°ΠΏΠΏΠ°ΡΠ°ΡΠ½Π°Ρ Π°ΡΡ ΠΈΡΠ΅ΠΊΡΡΡΠ° |
$OLDPWD | ΠΏΡΠ΅ΠΆΠ½ΠΈΠΉ ΡΠ°Π±ΠΎΡΠΈΠΉ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ |
$OSTYPE | ΡΠΈΠΏ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΠΎΠ½Π½ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΡ |
$PATH | ΠΏΡΡΡ ΠΏΠΎΠΈΡΠΊΠ° (Π²ΠΊΠ»ΡΡΠ°Π΅Ρ Π² ΡΠ΅Π±Ρ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ΠΈ /usr/bin/ , /usr/X11R6/bin/ , /usr/local/bin ΠΈ Ρ. Π΄.) |
$PIPESTATUS | ΠΠΎΠ΄ Π²ΠΎΠ·Π²ΡΠ°ΡΠ° ΠΊΠ°Π½Π°Π»Π° (ΠΊΠΎΠ½Π²Π΅ΠΉΠ΅ΡΠ°) |
$PPID | PID (ΠΈΠ΄Π΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΎΡ) ΡΠΎΠ΄ΠΈΡΠ΅Π»ΡΡΠΊΠΎΠ³ΠΎ ΠΏΡΠΎΡΠ΅ΡΡΠ° |
$PS1 | ΠΏΡΠΈΠ³Π»Π°ΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ |
$PS2 | Π²ΡΠΎΡΠΈΡΠ½ΠΎΠ΅ ΠΏΡΠΈΠ³Π»Π°ΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ, Π²ΡΠ²ΠΎΠ΄ΠΈΡΡΡ ΡΠΎΠ³Π΄Π°, ΠΊΠΎΠ³Π΄Π° ΠΎΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ ΠΎΠΆΠΈΠ΄Π°Π΅ΡΡΡ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΡΠΉ Π²Π²ΠΎΠ΄. ΠΠ±ΡΡΠ½ΠΎ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΡΡΡ ΠΊΠ°ΠΊ Β«>Β» |
$PS3 | ΡΡΠ΅ΡΠΈΡΠ½ΠΎΠ΅ ΠΏΡΠΈΠ³Π»Π°ΡΠ΅Π½ΠΈΠ΅, Π²ΡΠ²ΠΎΠ΄ΠΈΡΡΡ, ΠΊΠΎΠ³Π΄Π° ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ Π΄ΠΎΠ»ΠΆΠ΅Π½ ΡΠ΄Π΅Π»Π°ΡΡ Π²ΡΠ±ΠΎΡ Π² ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΠ΅ select |
$PS4 | ΠΏΡΠΈΠ³Π»Π°ΡΠ΅Π½ΠΈΠ΅ ΡΠ΅ΡΠ²ΡΡΡΠΎΠ³ΠΎ ΡΡΠΎΠ²Π½Ρ, Π²ΡΠ²ΠΎΠ΄ΠΈΡΡΡ (Π² ΠΈΠ·ΠΌΠ΅Π½ΡΠ½Π½ΠΎΠΌ Π²ΠΈΠ΄Π΅) Π² Π½Π°ΡΠ°Π»Π΅ ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΡΡΡΠΎΠΊΠΈ ΠΎΡΠ»Π°Π΄ΠΎΡΠ½ΠΎΠ³ΠΎ Π²ΡΠ²ΠΎΠ΄Π° ΡΠΎΠ³Π΄Π°, ΠΊΠΎΠ³Π΄Π° ΡΡΠ΅Π½Π°ΡΠΈΠΉ Π²ΡΠ·ΡΠ²Π°Π΅ΡΡΡ Ρ ΠΊΠ»ΡΡΠΎΠΌ -x . ΠΠ±ΡΡΠ½ΠΎ ΠΎΡΠΎΠ±ΡΠ°ΠΆΠ°Π΅ΡΡΡ ΠΊΠ°ΠΊ Β«+Β», Β«++Β» ΠΈ Ρ. Π΄. |
$PWD | ΡΠ°Π±ΠΎΡΠΈΠΉ (ΡΠ΅ΠΊΡΡΠΈΠΉ) ΠΊΠ°ΡΠ°Π»ΠΎΠ³ |
$REPLY | ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½Π°Ρ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ, ΠΊΡΠ΄Π° Π·Π°ΠΏΠΈΡΡΠ²Π°Π΅ΡΡΡ Π²Π²ΠΎΠ΄ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ, Π²ΡΠΏΠΎΠ»Π½Π΅Π½Π½ΡΠΉ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ read |
$SECONDS | Π²ΡΠ΅ΠΌΡ ΡΠ°Π±ΠΎΡΡ ΡΡΠ΅Π½Π°ΡΠΈΡ (Π² ΡΠ΅ΠΊΡΠ½Π΄Π°Ρ ) |
$SHELLOPTS | ΡΠΏΠΈΡΠΎΠΊ Π΄ΠΎΠΏΡΡΡΠΈΠΌΡΡ ΠΎΠΏΡΠΈΠΉ ΠΈΠ½ΡΠ΅ΡΠΏΡΠ΅ΡΠ°ΡΠΎΡΠ° (Π΄ΠΎΡΡΡΠΏΠ½Π° ΡΠΎΠ»ΡΠΊΠΎ Π΄Π»Ρ ΡΡΠ΅Π½ΠΈΡ) |
$SHLVL | ΡΡΠΎΠ²Π΅Π½Ρ Π²Π»ΠΎΠΆΠ΅Π½Π½ΠΎΡΡΠΈ shell |
Π Π΅Π³ΡΠ»ΡΡΠ½ΡΠ΅ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΡ Π²Π½ΡΡΡΠΈ ΠΏΡΠΎΡΠ΅ΡΡΠ°
Bash 3.0 ΠΏΠΎΠ΄Π΄Π΅ΡΠΆΠΈΠ²Π°Π΅Ρ Π²ΡΡΡΠΎΠ΅Π½Π½ΡΠ΅ ΡΠ΅Π³ΡΠ»ΡΡΠ½ΡΠ΅ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΡ Ρ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡΠΎΠΌ, ΠΏΠΎΠ΄ΠΎΠ±Π½ΡΠΌ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡΡ Perl :
[[ string = ~ regex ]]
Π‘ΠΈΠ½ΡΠ°ΠΊΡΠΈΡ ΡΠ΅Π³ΡΠ»ΡΡΠ½ΡΡ
Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΠΉ Π·Π°Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠΈΡΠΎΠ²Π°Π½ Π½Π° ΡΡΡΠ°Π½ΠΈΡΠ°Ρ
Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΡΠΈΠΈ man 7 regex. Π‘ΡΠ°ΡΡΡ Π²ΡΡ
ΠΎΠ΄Π° ΡΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅ΡΡΡ Π² 0, Π΅ΡΠ»ΠΈ ΡΠ΅Π³ΡΠ»ΡΡΠ½ΠΎΠ΅ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ ΡΠΎΠ²ΠΏΠ°Π»ΠΎ ΡΠΎ ΡΡΡΠΎΠΊΠΎΠΉ, ΠΈ 1, Π΅ΡΠ»ΠΈ Π½Π΅Ρ. ΠΠ½Π°ΡΠ΅Π½ΠΈΠ΅ ΠΏΠΎΠ΄Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΡ, Π·Π°ΠΊΠ»ΡΡΡΠ½Π½ΠΎΠ³ΠΎ Π² ΡΠΊΠΎΠ±ΠΊΠΈ, ΠΌΠΎΠΆΠ½ΠΎ ΠΏΠΎΠ»ΡΡΠΈΡΡ [7] ΡΠ΅ΡΠ΅Π· ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ ${BASH_REMATCH[@]} , Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ:
REGEXP = 'foo(bar)bl(.*)'
if [[ "abcfoobarbletch" = ~ $REGEXP ]]
then
echo "Π Π΅Π³ΡΠ»ΡΡΠ½ΠΎΠ΅ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ ΡΠΎΠ²ΠΏΠ°Π»ΠΎ ΡΠΎ ΡΡΡΠΎΠΊΠΎΠΉ!"
echo " $BASH_REMATCH " # Π²ΡΠ²ΠΎΠ΄ΠΈΡ: foobarbletch
echo " ${ BASH_REMATCH [1] } " # Π²ΡΠ²ΠΎΠ΄ΠΈΡ: bar
echo " ${ BASH_REMATCH [2] } " # Π²ΡΠ²ΠΎΠ΄ΠΈΡ: etch
fi
ΠΡΡΡΠΎΠ΅Π½Π½ΡΠ΅ ΡΠ΅Π³ΡΠ»ΡΡΠ½ΡΠ΅ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΡ ΠΎΠ±ΡΡΠ½ΠΎ ΡΠ°Π±ΠΎΡΠ°ΡΡ Π±ΡΡΡΡΠ΅Π΅, ΡΠ΅ΠΌ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ Π²Π½Π΅ΡΠ½Π΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Ρ grep, ΠΏΠΎΡΠΎΠΌΡ ΡΡΠΎ ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΡΡΡΠ΅Π΅ ΡΠ΅Π³ΡΠ»ΡΡΠ½ΠΎΠ΅ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ Π² ΡΠ°ΠΌΠΊΠ°Ρ
ΠΏΡΠΎΡΠ΅ΡΡΠ° bash. ΠΡΠ»ΠΈ ΡΠ΅Π³ΡΠ»ΡΡΠ½ΠΎΠ΅ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ ΠΈΠ»ΠΈ ΡΡΡΠΎΠΊΠ° ΡΠΎΠ΄Π΅ΡΠΆΠ°Ρ ΠΏΡΠΎΠ±Π΅Π»Ρ ΠΈΠ»ΠΈ ΠΌΠ΅ΡΠ°ΡΠΈΠΌΠ²ΠΎΠ»Ρ (ΡΠ°ΠΊΠΈΠ΅ ΠΊΠ°ΠΊ * ΠΈΠ»ΠΈ ? ), ΠΈΡ
ΡΠ»Π΅Π΄ΡΠ΅Ρ Π²Π·ΡΡΡ Π² ΠΊΠ°Π²ΡΡΠΊΠΈ. Π Π΅ΠΊΠΎΠΌΠ΅Π½Π΄ΡΠ΅ΡΡΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ Π΄Π»Ρ Ρ
ΡΠ°Π½Π΅Π½ΠΈΡ ΡΠ΅Π³ΡΠ»ΡΡΠ½ΠΎΠ³ΠΎ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΡ, ΠΊΠ°ΠΊ Π² Π²ΡΡΠ΅ΠΏΡΠΈΠ²Π΅Π΄ΡΠ½Π½ΠΎΠΌ ΠΏΡΠΈΠΌΠ΅ΡΠ΅, Π΄Π»Ρ ΠΈΠ·Π±Π΅ΠΆΠ°Π½ΠΈΡ ΠΏΡΠΎΠ±Π»Π΅ΠΌ Ρ ΡΠΊΡΠ°Π½ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΡΠΏΠ΅ΡΠΈΠ°Π»ΡΠ½ΡΡ
ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ². ΠΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π²ΡΠ²ΠΎΠ΄ bash Ρ ΠΎΠΏΡΠΈΠ΅ΠΉ -x Π΄Π»Ρ ΠΏΡΠΎΠ²Π΅ΡΠΊΠΈ, ΠΊΠ°ΠΊ ΠΈΠΌΠ΅Π½Π½ΠΎ bash Π²ΠΎΡΠΏΡΠΈΠ½ΠΈΠΌΠ°Π΅Ρ Π²Π°ΡΠ΅ ΡΠ΅Π³ΡΠ»ΡΡΠ½ΠΎΠ΅ Π²ΡΡΠ°ΠΆΠ΅Π½ΠΈΠ΅.
Π Π°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ ΡΠΊΠΎΠ±ΠΎΠΊ
ΠΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΡ ΡΠΊΠΎΠ±ΠΎΠΊ Π·Π°ΠΈΠΌΡΡΠ²ΠΎΠ²Π°Π½Π° Ρ csh . ΠΠ½Π° ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΠΏΡΠΎΠΈΠ·Π²ΠΎΠ»ΡΠ½ΠΎΠΉ ΡΡΡΠΎΠΊΠ΅ Π±ΡΡΡ ΡΡΠΎΡΠΌΠΈΡΠΎΠ²Π°Π½Π½ΠΎΠΉ Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ΠΌ ΠΏΠΎΡ ΠΎΠΆΠ΅ΠΉ ΡΠ΅Ρ Π½ΠΈΠΊΠΈ, ΠΊΠ°ΠΊ ΡΡΠΎ Π΄Π΅Π»Π°Π΅ΡΡΡ Ρ Π½Π°Π·Π²Π°Π½ΠΈΡΠΌΠΈ ΡΠ°ΠΉΠ»ΠΎΠ². ΠΠ΄Π½Π°ΠΊΠΎ Π² bash ΡΠ³Π΅Π½Π΅ΡΠΈΡΠΎΠ²Π°Π½Π½ΡΠ΅ ΡΡΡΠΎΠΊΠΈ Π½Π΅ ΠΎΠ±ΡΠ·Π°Π½Ρ Π±ΡΡΡ ΠΈΠΌΠ΅Π½Π°ΠΌΠΈ ΡΠ°ΠΉΠ»ΠΎΠ². Π Π΅Π·ΡΠ»ΡΡΠ°Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΡ ΡΡΡΠΎΠΊΠΈ Π½Π΅ ΡΠΎΡΡΠΈΡΡΠ΅ΡΡΡ, ΡΠΎΡ ΡΠ°Π½ΡΠ΅ΡΡΡ ΠΏΠΎΡΡΠ΄ΠΎΠΊ ΡΠ»Π΅Π²Π° Π½Π°ΠΏΡΠ°Π²ΠΎ:
# ΠΡΠΎ ΠΎΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΡ ΠΏΡΠΈΡΡΡΠ°Ρ bash
echo a { p,c,d,b } e # ape ace ade abe
ΠΠ΅ ΡΠ»Π΅Π΄ΡΠ΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΡΡΡ ΠΎΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΡ, Π΅ΡΠ»ΠΈ ΡΠΊΡΠΈΠΏΡ ΠΏΠ»Π°Π½ΠΈΡΡΠ΅ΡΡΡ ΠΏΠΎΡΡΠΈΡΠΎΠ²Π°ΡΡ, ΠΏΠΎΡΠΎΠΌΡ ΡΡΠΎ Π² ΡΡΠ°Π΄ΠΈΡΠΈΠΎΠ½Π½ΡΡ ΡΠΊΡΠΈΠΏΡΠ°Ρ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ ΡΡΡΠΎΠΊΠΈ Π½Π΅ Π±ΡΠ΄Π΅Ρ Π΄Π΅ΠΉΡΡΠ²ΠΎΠ²Π°ΡΡ:
# Π’ΡΠ°Π΄ΠΈΡΠΈΠΎΠ½Π½Π°Ρ ΠΎΠ±ΠΎΠ»ΠΎΡΠΊΠ° Π½Π΅ Π΄Π°ΡΡ ΡΠΎΡ ΠΆΠ΅ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ
echo a { p,c,d,b } e # a{p,c,d,b}e
ΠΠΎΠ³Π΄Π° ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ ΡΠΊΠΎΠ±ΠΎΠΊ Π² ΡΠΎΡΠ΅ΡΠ°Π½ΠΈΠΈ Ρ ΡΠΈΠΌΠ²ΠΎΠ»Π°ΠΌΠΈ ΠΏΠΎΠ΄ΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ, ΡΠΊΠΎΠ±ΠΊΠΈ ΡΠ°ΡΠΊΡΡΠ²Π°ΡΡΡΡ ΠΏΠ΅ΡΠ²ΡΠΌΠΈ, Π° Π·Π°ΡΠ΅ΠΌ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ ΠΎΠ±ΡΠ°Π±Π°ΡΡΠ²Π°Π΅ΡΡΡ Π² ΠΎΠ±ΡΡΠ½ΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅. Π’Π°ΠΊΠΈΠΌ ΠΎΠ±ΡΠ°Π·ΠΎΠΌ, ΡΠΏΠΈΡΠΎΠΊ JPEG- ΠΈ PNG-ΠΈΠ·ΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠΉ Π² ΡΠ΅ΠΊΡΡΠ΅ΠΌ ΠΊΠ°ΡΠ°Π»ΠΎΠ³Π΅ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΏΠΎΠ»ΡΡΠ΅Π½ ΡΠ°ΠΊ:
ls *. { jpg,jpeg,png } # ΡΠΊΠΎΠ±ΠΊΠΈ ΡΠ°ΡΠΊΡΡΠ²Π°ΡΡΡΡ Π΄ΠΎ *.jpg *.jpeg *.png, ΠΏΠΎΡΠ»Π΅ ΡΠ΅Π³ΠΎ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅ΡΡΡ ΠΏΠΎΠΈΡΠΊ ΠΏΠΎ ΠΌΠ°ΡΠΊΠ°ΠΌ
ΠΠΎΡΡΡΠΈΠ΅ ΠΊΠ»Π°Π²ΠΈΡΠΈ
- Tab βΉ : ΠΠ²ΡΠΎΠ΄ΠΎΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅ ΡΡΡΠΎΠΊΠΈ Π·Π° ΠΊΡΡΡΠΎΡΠΎΠΌ.
- Ctrl + ! Ctrl + ! : ΠΠΎΠ²ΡΠΎΡΠΈΡΡ ΠΏΠΎΡΠ»Π΅Π΄Π½ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ.
- Ctrl + a : ΠΠ΅ΡΠ΅ΠΌΠ΅ΡΠ°Π΅Ρ ΠΊΡΡΡΠΎΡ Π² Π½Π°ΡΠ°Π»ΠΎ ΡΡΡΠΎΠΊΠΈ (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ Home ).
- Ctrl + b : ΠΠ΅ΡΠ΅ΠΌΠ΅ΡΠ°Π΅Ρ ΠΊΡΡΡΠΎΡ Π½Π° ΠΎΠ΄ΠΈΠ½ ΡΠΈΠΌΠ²ΠΎΠ» Π½Π°Π·Π°Π΄ (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ β ).
- Ctrl + r : ΠΠΎΠΈΡΠΊ ΠΏΠΎ Π½Π°Π±ΡΠ°Π½Π½ΡΠΌ ΡΠ°Π½Π΅Π΅ ΠΊΠΎΠΌΠ°Π½Π΄Π°ΠΌ.
- Ctrl + c : ΠΠΎΡΡΠ»Π°Π΅Ρ ΡΠΈΠ³Π½Π°Π» SIGINT ΡΠ΅ΠΊΡΡΠ΅ΠΌΡ Π·Π°Π΄Π°Π½ΠΈΡ, ΠΊΠΎΡΠΎΡΡΠΉ ΠΎΠ±ΡΡΠ½ΠΎ (Π½ΠΎ Π½Π΅ Π²ΡΠ΅Π³Π΄Π°) ΠΏΡΠ΅ΠΊΡΠ°ΡΠ°Π΅Ρ ΠΈ Π·Π°ΠΊΡΡΠ²Π°Π΅Ρ Π΅Π³ΠΎ.
- Ctrl + d : ΠΠΎΡΡΠ»Π°Π΅Ρ ΠΌΠ°ΡΠΊΠ΅Ρ EOF , ΠΊΠΎΡΠΎΡΡΠΉ (Π΅ΡΠ»ΠΈ Π½Π΅ ΠΎΡΠΊΠ»ΡΡΠ΅Π½ΠΎ ΠΎΠΏΡΠΈΠ΅ΠΉ ΠΈ ΡΠ΅ΠΊΡΡΠ°Ρ ΡΡΡΠΎΠΊΠ° Π½Π΅ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ ΡΠ΅ΠΊΡΡΠ°) Π·Π°ΠΊΡΡΠ²Π°Π΅Ρ ΡΠ΅ΠΊΡΡΡΡ ΠΎΠ±ΠΎΠ»ΠΎΡΠΊΡ (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Π΅ exit ), ΠΏΡΠΈ Π²Π²ΠΎΠ΄Π΅ Π² ΠΈΡΠΏΠΎΠ»Π½ΡΡΡΡΡΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ Π·Π°Π²Π΅ΡΡΠ°Π΅Ρ Π²Π²ΠΎΠ΄, Π΅ΡΠ»ΠΈ Π² ΡΡΡΠΎΠΊΠ΅ Π½Π΅Ρ ΡΠ΅ΠΊΡΡΠ°, ΠΈΠ½Π°ΡΠ΅ Π·Π°Π²Π΅ΡΡΠ°Π΅Ρ ΡΡΡΠΎΠΊΡ Π±Π΅Π· ΡΠΈΠΌΠ²ΠΎΠ»Π° Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΡ ΡΡΡΠΎΠΊΠΈ.
- Ctrl + d : Π£Π΄Π°Π»ΡΠ΅Ρ ΡΠ΅ΠΊΡΡΠΈΠΉ ΡΠΈΠΌΠ²ΠΎΠ» (ΡΠΎΠ»ΡΠΊΠΎ Π΅ΡΠ»ΠΈ Π΅ΡΡΡ ΡΠ΅ΠΊΡΡ Π½Π° ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΡΡΡΠΎΠΊΠ΅) (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ Delete ).
- Ctrl + e : ΠΠ΅ΡΠ΅ΠΌΠ΅ΡΠ°Π΅Ρ ΠΊΡΡΡΠΎΡ Π² ΠΊΠΎΠ½Π΅Ρ ΡΡΡΠΎΠΊΠΈ (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ End ).
- Ctrl + f : ΠΠ΅ΡΠ΅ΠΌΠ΅ΡΠ°Π΅Ρ ΠΊΡΡΡΠΎΡ Π½Π° ΠΎΠ΄ΠΈΠ½ ΡΠΈΠΌΠ²ΠΎΠ» Π²ΠΏΠ΅ΡΡΠ΄ (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ β ).
- Ctrl + h : Π£Π΄Π°Π»ΡΠ΅Ρ ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠΈΠΉ ΡΠΈΠΌΠ²ΠΎΠ» (ΡΠΎ ΠΆΠ΅ ΡΠ°ΠΌΠΎΠ΅, ΡΡΠΎ ΠΈ ΠΊΠ»Π°Π²ΠΈΡΠ° β Backspace ).
- Ctrl + i : ΠΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ Tab βΉ .
- Ctrl + j : ΠΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ β΅ Enter .
- Ctrl + k : ΠΡΠΈΡΠ°Π΅Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ ΡΡΡΠΎΠΊΠΈ ΠΏΠΎΡΠ»Π΅ ΠΊΡΡΡΠΎΡΠ° ΠΈ ΠΊΠΎΠΏΠΈΡΡΠ΅Ρ ΡΡΠΎ Π² Π±ΡΡΠ΅Ρ ΠΎΠ±ΠΌΠ΅Π½Π° ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡΠ° bash (kill ring).
- Ctrl + l : ΠΡΠΈΡΠ°Π΅Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ ΡΠΊΡΠ°Π½Π° (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠΎΠΌΠ°Π½Π΄Π΅
clear). - Ctrl + m : ΠΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ β΅ Enter .
- Ctrl + n : (ΡΠ»Π΅Π΄ΡΡΡΠ΅Π΅) ΠΏΠ΅ΡΠ΅Π»ΠΈΡΡΡΠ²Π°Π΅Ρ ΠΊ ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Π΅ (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ β ).
- Ctrl + o : ΠΡΠΏΠΎΠ»Π½ΡΠ΅Ρ Π½Π°ΠΉΠ΄Π΅Π½Π½ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ Π² ΠΈΡΡΠΎΡΠΈΠΈ, ΠΈ Π²ΡΠ±ΠΈΡΠ°Π΅Ρ ΡΠ»Π΅Π΄ΡΡΡΡΡ ΡΡΡΠΎΠΊΡ ΠΎΡΠ½ΠΎΡΠΈΡΠ΅Π»ΡΠ½ΠΎ ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΡΡΡΠΎΠΊΠΈ Π² ΠΈΡΡΠΎΡΠΈΠΈ Π΄Π»Ρ ΡΠΎΠ³ΠΎ, ΡΡΠΎΠ±Ρ ΠΎΡΡΠ΅Π΄Π°ΠΊΡΠΈΡΠΎΠ²Π°ΡΡ.
- Ctrl + p : (ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅Π΅) ΠΏΠ΅ΡΠ΅Π»ΠΈΡΡΡΠ²Π°Π΅Ρ ΠΊ ΠΏΡΠ΅Π΄ΡΠ΅ΡΡΠ²ΡΡΡΠ΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Π΅ (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ β ).
- Ctrl + q : ΠΠΎΠ·ΠΎΠ±Π½ΠΎΠ²ΠΈΡΡ Π²ΡΠ²ΠΎΠ΄ ΠΏΡΠΎΡΠ΅ΡΡΠ°.
- Ctrl + s : ΠΡΠΈΠΎΡΡΠ°Π½ΠΎΠ²ΠΈΡΡ Π²ΡΠ²ΠΎΠ΄ ΠΏΡΠΎΡΠ΅ΡΡΠ° (stop).
- Ctrl + t : ΠΠ±ΠΌΠ΅Π½ ΠΌΠ΅ΡΡΠ°ΠΌΠΈ ΡΠΎΡΠ΅Π΄Π½ΠΈΡ ΡΠΈΠΌΠ²ΠΎΠ»ΠΎΠ².
- Ctrl + u : ΠΡΠΈΡΠ°Π΅Ρ ΡΠΎΠ΄Π΅ΡΠΆΠ°Π½ΠΈΠ΅ ΡΡΡΠΎΠΊΠΈ Π΄ΠΎ ΠΊΡΡΡΠΎΡΠ° ΠΈ ΠΊΠΎΠΏΠΈΡΡΠ΅Ρ Π΅Π³ΠΎ Π² Π±ΡΡΠ΅Ρ ΠΎΠ±ΠΌΠ΅Π½Π° ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡΠ° bash (kill ring).
- Ctrl + w : Π£Π±ΠΈΡΠ°Π΅Ρ ΡΠ»ΠΎΠ²ΠΎ Π΄ΠΎ ΠΊΡΡΡΠΎΡΠ° ΠΈ ΠΊΠΎΠΏΠΈΡΡΠ΅Ρ Π΅Π³ΠΎ Π² Π±ΡΡΠ΅Ρ ΠΎΠ±ΠΌΠ΅Π½Π° ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡΠ° bash (kill ring).
- Ctrl + y : Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΠΌΠΎΠ΅ Π±ΡΡΠ΅ΡΠ° ΠΎΠ±ΠΌΠ΅Π½Π° ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡΠ° bash ΠΎΡ ΠΏΠΎΠ·ΠΈΡΠΈΠΈ ΠΊΡΡΡΠΎΡΠ°.
- Ctrl + z : ΠΠΎΡΡΠ»Π°Π΅Ρ ΡΠΈΠ³Π½Π°Π» SIGTSTP ΡΠ΅ΠΊΡΡΠ΅ΠΌΡ Π·Π°Π΄Π°Π½ΠΈΡ, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΡΠΈΠΎΡΡΠ°Π½Π°Π²Π»ΠΈΠ²Π°Π΅Ρ Π΅Π³ΠΎ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΠ΅, ΠΈ Π²ΠΎΠ·ΠΎΠ±Π½ΠΎΠ²Π»ΡΠ΅Ρ ΠΏΡΠΈΡΠΌ ΠΊΠΎΠΌΠ°Π½Π΄. ΠΠ»Ρ Π²ΠΎΠ·ΠΎΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΡ Π΅Π³ΠΎ Π²ΡΠΏΠΎΠ»Π½Π΅Π½ΠΈΡ Π² ΡΠΎΠ½ΠΎΠ²ΠΎΠΌ ΡΠ΅ΠΆΠΈΠΌΠ΅ ΠΌΠΎΠΆΠ½ΠΎ Π²Π²Π΅ΡΡΠΈ ΠΊΠΎΠΌΠ°Π½Π΄Ρ bg. ΠΠ»Ρ ΡΠΎΠ³ΠΎ, ΡΡΠΎΠ±Ρ Π²Π΅ΡΠ½ΡΡΡ Π΅Π³ΠΎ ΠΈΠ· ΡΠΎΠ½ΠΎΠ²ΠΎΠ³ΠΎ ΡΠ΅ΠΆΠΈΠΌΠ° ΠΈΠ»ΠΈ ΠΏΡΠΈΠΎΡΡΠ°Π½ΠΎΠ²ΠΊΠΈ, ΠΌΠΎΠΆΠ½ΠΎ Π²ΡΠΏΠΎΠ»Π½ΠΈΡΡ fg.
- Ctrl + / : ΠΡΠ΅ΡΠ²Π°ΡΡ ΡΠ΅ΠΊΡΡΠΈΠΉ ΠΏΡΠΎΡΠ΅ΡΡ Ρ Π΄Π°ΠΌΠΏΠΎΠΌ ΠΏΠ°ΠΌΡΡΠΈ (core dump), ΠΏΠΎΡΠ»Π°Π² Π΅ΠΌΡ ΡΠΈΠ³Π½Π°Π».
- Ctrl + _ ( Ctrl + β§ Shift + - ): ΠΡΠΊΠ°Ρ ΡΠ΅Π΄Π°ΠΊΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ.
- Alt + > : ΠΏΠ΅ΡΠ΅Ρ ΠΎΠ΄ ΠΊ ΠΏΠΎΡΠ»Π΅Π΄Π½Π΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Π΅ Π² ΠΈΡΡΠΎΡΠΈΠΈ.
- Alt + b : (Π½Π°Π·Π°Π΄) ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ°Π΅Ρ ΠΊΡΡΡΠΎΡ Π½Π°Π·Π°Π΄ Π½Π° ΠΎΠ΄Π½ΠΎ ΡΠ»ΠΎΠ²ΠΎ (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ Ctrl + β ).
- Alt + d : Π‘ΠΎΠΊΡΠ°ΡΠ°Π΅Ρ ΡΠ»ΠΎΠ²ΠΎ ΠΏΠΎΡΠ»Π΅ ΠΊΡΡΡΠΎΡΠ°.
- Alt + f : (Π²ΠΏΠ΅ΡΡΠ΄) ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ°Π΅Ρ ΠΊΡΡΡΠΎΡ Π²ΠΏΠ΅ΡΡΠ΄ Π½Π° ΠΎΠ΄Π½ΠΎ ΡΠ»ΠΎΠ²ΠΎ (ΡΠΊΠ²ΠΈΠ²Π°Π»Π΅Π½ΡΠ½ΠΎ ΠΊΠ»Π°Π²ΠΈΡΠ΅ Ctrl + β ).
- Alt + t : ΠΠ΅Π½ΡΠ΅Ρ Π΄Π²Π° ΡΠ»ΠΎΠ²Π° ΠΏΠ΅ΡΠ΅Π΄ ΠΊΡΡΡΠΎΡΠΎΠΌ ΠΌΠ΅ΡΡΠ°ΠΌΠΈ.
- Alt + . : ΠΠΎΠ±Π°Π²Π»ΡΠ΅Ρ ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΠΉ Π°ΡΠ³ΡΠΌΠ΅Π½Ρ ΠΏΡΠ΅Π΄ΡΠ΄ΡΡΠ΅ΠΉ ΠΊΠΎΠΌΠ°Π½Π΄Ρ.
- Alt + c : ΠΠ°ΠΌΠ΅Π½ΠΈΡΡ Π±ΡΠΊΠ²Ρ ΠΏΠΎΠ΄ ΠΊΡΡΡΠΎΡΠΎΠΌ Π½Π° Π·Π°Π³Π»Π°Π²Π½ΡΡ.
- Alt + l : ΠΠ°ΠΌΠ΅Π½ΠΈΡΡ Π±ΡΠΊΠ²Ρ ΠΏΠΎΠ΄ ΠΊΡΡΡΠΎΡΠΎΠΌ Π½Π° ΡΡΡΠΎΡΠ½ΡΡ.
- Ctrl + x Ctrl + x : ΠΠ΅ΡΠ΅Π½ΠΎΡΠΈΡ ΠΊΡΡΡΠΎΡ ΠΊ Π½Π°ΡΠ°Π»Ρ ΡΡΡΠΎΠΊΠΈ ΠΎΡ ΡΠ΅ΠΊΡΡΠ΅ΠΉ ΠΏΠΎΠ·ΠΈΡΠΈΠΈ, ΠΈ ΠΎΠ±ΡΠ°ΡΠ½ΠΎ.
- Ctrl + x Ctrl + e : Π Π΅Π΄Π°ΠΊΡΠΈΡΡΠ΅Ρ ΡΠ΅ΠΊΡΡΡΡ ΡΡΡΠΎΠΊΡ Π² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ΅ $EDITOR, ΠΈΠ»ΠΈ vi, Π΅ΡΠ»ΠΈ Π½Π΅ ΠΏΡΠ΅Π΄ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½ΠΎ.
- Ctrl + x Ctrl + v : ΠΡΠ²ΠΎΠ΄ Π½Π° ΡΠΊΡΠ°Π½ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΠΈ ΠΎ Π²Π΅ΡΡΠΈΠΈ ΡΠ΅ΠΊΡΡΠ΅Π³ΠΎ ΡΠΊΠ·Π΅ΠΌΠΏΠ»ΡΡΠ° bash.
Π‘ΡΠ°ΡΡΠΎΠ²ΡΠ΅ ΡΠΊΡΠΈΠΏΡΡ
Bash ΠΏΡΠΈ Π·Π°ΠΏΡΡΠΊΠ΅ Π²ΡΠ·ΡΠ²Π°Π΅Ρ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΠΈΠ· ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π° ΡΠ°Π·Π»ΠΈΡΠ½ΡΡ ΡΠΊΡΠΈΠΏΡΠΎΠ².
ΠΠΎΠ³Π΄Π° bash Π²ΡΠ·ΡΠ²Π°Π΅ΡΡΡ ΠΊΠ°ΠΊ ΠΈΠ½ΡΠ΅ΡΠ°ΠΊΡΠΈΠ²Π½Π°Ρ ΠΎΠ±ΠΎΠ»ΠΎΡΠΊΠ° Π²Ρ
ΠΎΠ΄Π° Π² ΡΠΈΡΡΠ΅ΠΌΡ, ΠΏΠ΅ΡΠ²ΡΠΌ Π΄Π΅Π»ΠΎΠΌ ΠΎΠ½ ΡΠΈΡΠ°Π΅Ρ ΠΈ Π²ΡΠ·ΡΠ²Π°Π΅Ρ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΠΈΠ· ΡΠ°ΠΉΠ»Π° /etc/profile , Π΅ΡΠ»ΠΈ ΡΡΠΎΡ ΡΠ°ΠΉΠ» ΡΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ. ΠΠΎΡΠ»Π΅ ΡΡΠ΅Π½ΠΈΡ ΡΡΠΎΠ³ΠΎ ΡΠ°ΠΉΠ»Π° ΠΎΠ½ ΡΠΌΠΎΡΡΠΈΡ ΡΠ»Π΅Π΄ΡΡΡΠΈΠ΅ ΡΠ°ΠΉΠ»Ρ Π² ΡΠ»Π΅Π΄ΡΡΡΠ΅ΠΌ ΠΏΠΎΡΡΠ΄ΠΊΠ΅: ~/.bash_profile , ~/.bash_login ΠΈ ~/.profile , ΡΠΈΡΠ°Π΅Ρ ΠΈ Π²ΡΠ·ΡΠ²Π°Π΅Ρ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΠΈΠ· ΠΏΠ΅ΡΠ²ΠΎΠ³ΠΎ, ΠΊΠΎΡΠΎΡΡΠΉ ΡΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ ΠΈ Π΄ΠΎΡΡΡΠΏΠ΅Π½ Π΄Π»Ρ ΡΡΠ΅Π½ΠΈΡ. ΠΡΠΈ Π²ΡΡ
ΠΎΠ΄Π΅ bash ΡΠΈΡΠ°Π΅Ρ ΠΈ Π²ΡΠΏΠΎΠ»Π½ΡΠ΅Ρ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΠΈΠ· ΡΠ°ΠΉΠ»Π° ~/.bash_logout .
ΠΠΎΠ³Π΄Π° Π·Π°ΠΏΡΡΠΊΠ°Π΅ΡΡΡ ΠΈΠ½ΡΠ΅ΡΠ°ΠΊΡΠΈΠ²Π½Π°Ρ ΠΎΠ±ΠΎΠ»ΠΎΡΠΊΠ°, Π½ΠΎ Π½Π΅ Π΄Π»Ρ Π²Ρ
ΠΎΠ΄Π° Π² ΡΠΈΡΡΠ΅ΠΌΡ, bash ΡΠΈΡΠ°Π΅Ρ ΠΈ ΠΈΡΠΏΠΎΠ»Π½ΡΠ΅Ρ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΠΈΠ· ΡΠ°ΠΉΠ»ΠΎΠ² /etc/bash.bashrc ΠΈ ~/.bashrc , Π΅ΡΠ»ΠΈ ΠΎΠ½ΠΈ ΡΡΡΠ΅ΡΡΠ²ΡΡΡ. ΠΡΠΎ ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΎΡΠΌΠ΅Π½Π΅Π½ΠΎ ΠΎΠΏΡΠΈΠ΅ΠΉ -norc . ΠΠΏΡΠΈΡ -rcfile file Π·Π°ΡΡΠ°Π²ΠΈΡ bash ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρ ΠΈΠ· ΡΠ°ΠΉΠ»Π° file Π²ΠΌΠ΅ΡΡΠΎ /etc/bash.bashrc ΠΈ ~/.bashrc .
ΠΠ΅ΡΠ΅Π½ΠΎΡΠΈΠΌΠΎΡΡΡ
ΠΠ΅ΡΠ²ΠΎΠΉ ΡΡΡΠΎΠΊΠΎΠΉ ΡΠΊΡΠΈΠΏΡΠ° Π΄ΠΎΠ»ΠΆΠ½Π° Π±ΡΡΡ Π·Π°ΠΏΠΈΡΡ #!/bin/bash , Π΅ΡΠ»ΠΈ ΠΈΠ·Π²Π΅ΡΡΠ΅Π½ Π°Π±ΡΠΎΠ»ΡΡΠ½ΡΠΉ ΠΏΡΡΡ ΠΊ ΠΈΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌΠΎΠΌΡ ΡΠ°ΠΉΠ»Ρ, Π»ΠΈΠ±ΠΎ #!/usr/bin/env bash Π΄Π»Ρ Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠ³ΠΎ ΠΎΠΏΡΠ΅Π΄Π΅Π»Π΅Π½ΠΈΡ ΠΏΡΡΠΈ ΠΊ ΠΈΡΠΏΠΎΠ»Π½ΡΠ΅ΠΌΠΎΠΌΡ ΡΠ°ΠΉΠ»Ρ ΡΠ΅ΡΠ΅Π· ΠΊΠΎΠΌΠ°Π½Π΄Ρ env Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ ΠΎΠΊΡΡΠΆΠ΅Π½ΠΈΡ PATH [11] .
Π‘ΠΊΡΠΈΠΏΡΡ ΠΎΠ±ΠΎΠ»ΠΎΡΠ΅ΠΊ, Π½Π°ΠΏΠΈΡΠ°Π½Π½ΡΠ΅ ΡΠΎ ΡΠΏΠ΅ΡΠΈΡΠΈΡΠ΅ΡΠΊΠΈΠΌΠΈ Π΄Π»Ρ bash ΠΎΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΡΠΌΠΈ, Π½Π΅ Π±ΡΠ΄ΡΡ ΡΠ°Π±ΠΎΡΠ°ΡΡ Π½Π° ΡΠΈΡΡΠ΅ΠΌΠ°Ρ , Π³Π΄Π΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΡΡΡ Bourne shell (sh) ΠΈΠ»ΠΈ ΠΎΠ΄ΠΈΠ½ ΠΈΠ· Π΅Π³ΠΎ Π°Π½Π°Π»ΠΎΠ³ΠΎΠ² , Π΅ΡΠ»ΠΈ bash Π½Π΅ Π±ΡΠ» ΡΡΡΠ°Π½ΠΎΠ²Π»Π΅Π½ Π² ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ Π΄ΠΎΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»ΡΠ½ΠΎΠΉ ΠΎΠ±ΠΎΠ»ΠΎΡΠΊΠΈ. ΠΡΠ° ΠΏΡΠΎΠ±Π»Π΅ΠΌΠ° ΡΡΠ°Π»Π° ΠΎΡΠΎΠ±Π΅Π½Π½ΠΎ Π²Π°ΠΆΠ½ΠΎΠΉ, ΠΊΠΎΠ³Π΄Π° Ubuntu Π½Π°ΡΠ°Π» Ρ ΠΎΠΊΡΡΠ±ΡΡ 2006 Π³ΠΎΠ΄Π° ΠΏΠΎΡΡΠ°Π²Π»ΡΡΡ Debian Almquist shell (dash) ΠΊΠ°ΠΊ ΡΠΊΡΠΈΠΏΡΠΎΠ²ΡΡ ΠΎΠ±ΠΎΠ»ΠΎΡΠΊΡ ΠΏΠΎ ΡΠΌΠΎΠ»ΡΠ°Π½ΠΈΡ, ΡΡΠΎ ΠΏΡΠΈΠ²Π΅Π»ΠΎ ΠΊ Π½Π΅ΡΠ°Π±ΠΎΡΠΎΡΠΏΠΎΡΠΎΠ±Π½ΠΎΡΡΠΈ ΠΌΠ½ΠΎΠ³ΠΎΡΠΈΡΠ»Π΅Π½Π½ΡΡ ΡΠΊΡΠΈΠΏΡΠΎΠ².
ΠΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΠΉ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡ ΠΊ ΡΠΊΡΠΈΠΏΡΠ°ΠΌ
Π‘ΡΡΠ΅ΡΡΠ²ΡΠ΅Ρ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌ, ΠΏΠΎΠ·Π²ΠΎΠ»ΡΡΡΠΈΡ ΡΠΎΠ·Π΄Π°Π²Π°ΡΡ Π³ΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΠΉ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡ ΠΊ bash-ΡΠΊΡΠΈΠΏΡΠ°ΠΌ.
- dialog β ΡΡΠΈΠ»ΠΈΡΠ°, ΠΏΠΎΠ·Π²ΠΎΠ»ΡΡΡΠ°Ρ ΡΠΎΠ·Π΄Π°Π²Π°ΡΡ Π΄ΠΈΠ°Π»ΠΎΠ³ΠΎΠ²ΡΠ΅ ΠΎΠΊΠ½Π° Π² ΠΊΠΎΠ½ΡΠΎΠ»ΠΈ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅Ρ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ curses ΠΈ ncurses .
- whiptail β Π°Π½Π°Π»ΠΎΠ³ ΡΡΠΈΠ»ΠΈΡΡ dialog, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅Ρ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΡ newt .
- zenity β Π½Π°ΠΈΠ±ΠΎΠ»Π΅Π΅ ΠΏΠΎΠΏΡΠ»ΡΡΠ½ΠΎΠ΅ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ Π΄Π»Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π³ΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΎΠ³ΠΎ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΠ° ΠΊ ΡΠΊΡΠΈΠΏΡΠ°ΠΌ.
- kdialog β Π°Π½Π°Π»ΠΎΠ³ zenity Π² ΡΡΠ΅Π΄Π΅ KDE .
- yad β ΡΠΎΡΠΊ zenity, Ρ Π±ΠΎΠ»ΡΡΠΈΠΌΠΈ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡΠΌΠΈ.
- xdialog β Π·Π°ΠΌΠ΅Π½Π° dialog, ΠΏΡΠ΅Π΄Π½Π°Π·Π½Π°ΡΠ΅Π½Π½Π°Ρ Π΄Π»Ρ ΠΏΡΠΈΠ΄Π°Π½ΠΈΡ Π·Π°ΠΏΡΡΠΊΠ°Π΅ΠΌΡΠΌ ΠΈΠ· ΡΠ΅ΡΠΌΠΈΠ½Π°Π»Π° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ°ΠΌ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡΠ° X Window System .
- gtkdialog β Π½Π°ΠΈΠ±ΠΎΠ»Π΅Π΅ ΡΡΠ½ΠΊΡΠΈΠΎΠ½Π°Π»ΡΠ½Π°Ρ ΡΡΠΈΠ»ΠΈΡΠ° Π΄Π»Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π³ΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠΉ Π½Π° bash-ΡΠΊΡΠΈΠΏΡΠ°Ρ .
See also
- Π‘ΡΠ°Π²Π½Π΅Π½ΠΈΠ΅ ΠΊΠΎΠΌΠ°Π½Π΄Π½ΡΡ ΠΎΠ±ΠΎΠ»ΠΎΡΠ΅ΠΊ
- ΠΠ°ΠΊΠ΅ΡΠ½ΡΠΉ ΡΠ°ΠΉΠ»
- GNU Readline
Notes
- β Bash-5.0 release available β 2019.
- β William McCarty. Learning Debian GNU/Linux . 13. Conquering the BASH Shell (Π°Π½Π³Π».) . O'Reilly Media (6 October 1999) . Date of treatment December 6, 2018.
- β ΠΠ΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ Π²ΡΠ²Π΅ΡΡΠΈ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ, ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠ΅ΠΉ
-n(Π² ΠΎΡΠ»ΠΈΡΠΈΠ΅ ΠΎΡprintf -- '%s\n' "${ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½Π°Ρ}"), Ρ. ΠΊ.-nΠΈΠ½ΡΠ΅ΡΠΏΡΠ΅ΡΠΈΡΡΠ΅ΡΡΡ ΠΊΠ°ΠΊ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡ ΠΊΠΎΠΌΠ°Π½Π΄Ρecho. - β Bash Reference Manual .
- β Bash News .
- β BashGuide/TestsAndConditionals β Greg's Wiki.
- β 1 2 3 4 5 6 7 8 ΠΠ»Ρ ΠΏΠΎΠ»ΡΡΠ΅Π½ΠΈΡ Π΄Π΅ΠΉΡΡΠ²ΠΈΡΠ΅Π»ΡΠ½ΠΎ Π²ΡΠ΅Ρ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ², Π²ΠΊΠ»ΡΡΠ°Ρ ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ ΠΈΠ· ΠΏΡΠΎΠ±Π΅Π»ΠΎΠ² ΠΈ ΠΏΡΡΡΡΠ΅ ΡΡΡΠΎΠΊΠΈ, ΠΎΠ±ΡΠ·Π°ΡΠ΅Π»ΡΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΊΠ°Π²ΡΡΠΊΠΈ.
- β ΠΠ΄Π΅ΡΡ Π°ΠΏΠΎΡΡΡΠΎΡΡ ΡΠΏΠΎΡΡΠ΅Π±Π»Π΅Π½Ρ ΠΏΡΠ°Π²ΠΈΠ»ΡΠ½ΠΎ.
- β bash(1): GNU Bourne-Again SHell β Linux man page (Π°Π½Π³Π».) . linux.die.net. Date of treatment July 11, 2017.
- β Π£ΡΡΠ°ΡΠ΅Π²ΡΠΈΠΉ Π²Π°ΡΠΈΠ°Π½Ρ:
$[β¦]. - β env(1) β Linux manual page . man7.org. ΠΠ°ΡΠ° ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΡ 21 ΡΠ½Π²Π°ΡΡ 2017.
Links
- Bash Reference Manual (Π°Π½Π³Π».) . β ΠΡΠΈΡΠΈΠ°Π»ΡΠ½ΠΎΠ΅ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²ΠΎ. ΠΠ°ΡΠ° ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΡ 22 Π½ΠΎΡΠ±ΡΡ 2010. ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΎ 23 Π°Π²Π³ΡΡΡΠ° 2011 Π³ΠΎΠ΄Π°.
- Bash Reference Manual . β ΠΠ΅ΡΠ΅Π²ΠΎΠ΄ man -ΡΡΡΠ°Π½ΠΈΡΡ ΠΎΡ 2004 Π³ΠΎΠ΄Π°. ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΎ 18 ΠΌΠ°Ρ 2012 Π³ΠΎΠ΄Π°.
- Advanced Bash-Scripting Guide . β Π Π°ΡΡΠΈΡΠ΅Π½Π½ΠΎΠ΅ ΡΡΠΊΠΎΠ²ΠΎΠ΄ΡΡΠ²ΠΎ ΠΏΠΎ Π½Π°ΠΏΠΈΡΠ°Π½ΠΈΡ bash-ΡΠΊΡΠΈΠΏΡΠΎΠ². ΠΠ°ΡΠ° ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΡ 6 Π°Π²Π³ΡΡΡΠ° 2011. ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΎ 23 Π°Π²Π³ΡΡΡΠ° 2011 Π³ΠΎΠ΄Π°.
- Π§Π°ΡΡΡΠ΅ ΠΎΡΠΈΠ±ΠΊΠΈ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π½Π° Bash . ΠΠ°ΡΠ° ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΡ 22 Π½ΠΎΡΠ±ΡΡ 2010. ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΎ 23 Π°Π²Π³ΡΡΡΠ° 2011 Π³ΠΎΠ΄Π°.
- ΠΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ Π² ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ Π½Π° bash . ΠΠ°ΡΠ° ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΡ 22 Π½ΠΎΡΠ±ΡΡ 2010. ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΎ 23 Π°Π²Π³ΡΡΡΠ° 2011 Π³ΠΎΠ΄Π°.
- Bash . openSuse wiki. ΠΠ°ΡΠ° ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΡ 22 Π½ΠΎΡΠ±ΡΡ 2010. ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΎ 23 Π°Π²Π³ΡΡΡΠ° 2011 Π³ΠΎΠ΄Π°.
- ΠΠΏΠΈΡΠ°Π½ΠΈΠ΅ ΠΊΠΎΠΌΠ°Π½Π΄ bash (Π°Π½Π³Π».) . ΠΠ°ΡΠ° ΠΎΠ±ΡΠ°ΡΠ΅Π½ΠΈΡ 22 Π½ΠΎΡΠ±ΡΡ 2010. ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΎ 23 Π°Π²Π³ΡΡΡΠ° 2011 Π³ΠΎΠ΄Π°.
- Π―Π½ Π¨ΠΈΠ»Π΄Ρ (Ian Shields). ΠΠΎΠ»Π΅Π·Π½ΡΠ΅ ΡΠΎΠ²Π΅ΡΡ Linux: ΠΠ°ΡΠ°ΠΌΠ΅ΡΡΡ bash ΠΈ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΡ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠΎΠ² . ΠΡΡ ΠΈΠ²ΠΈΡΠΎΠ²Π°Π½ΠΎ 15 ΠΎΠΊΡΡΠ±ΡΡ 2012 Π³ΠΎΠ΄Π°.