Bash Regular Expressions: Creation Guide, Application, Examples

Bash , . , , , - .

Command language history




Bash GNU Bourne. 1989 Linux MacOS Apple ( OS X). Windows 10 Solaris 11.

Bash - , , , . Bash , . Unix ( ), , , . csh ksh. Bash - POSIX- , . - Bourne-again shell.





"" 10 1988 , , . Bash - 8 1989 1992 1994 , , .

Bash Linux, , MacOS Apple. Bash Microsoft Win Cygwin, DOS DJGPP Android .

2014 "" 1.03, 1989 , Shellshock, . , CGI Bash , . , .

Bash Bourne , , . Bourne , , - . Bash grep, GNU , .





, Bash , , . , , . Bash , Bourne.

Bash: , ((...)) $ ((...)) , -. , (stdout) (stderr) &>. , Bourne ' command > file 2>&1'.

Bash "" (), . «», Bash Bourne Korn, Korn «», , , POSIX-.

- Bourne Korn, , Bash. , AWK. Bash 4.x MacOS - . .

Associative array example




command

: . «;». Bash, :

  • command1;
  • command2.

, 1 , 2. 1 (symbol &) , , .

Command Execution Modes




1 2 :

  • command1 & command2.

1 & symbol, , 2 . Bash grep , Ctrl + z, . , , , , jobs.

. "fg" , "bg"- , . Bg" "fg" , , . , «» "jobs". "kill" , . :

  • kill -s SIGKILL% 1 kill -9%.

Bash « » , "contingent" , . , "bashbug", . , . Bash , , , Bash.

Bash.

Reserved Bash Variables




Bash , . , , :

  • #!/bin/bash.
Scripts for launching an interactive environment




, Bash . :

  1. [edit] /etc/profile, .
  2. /etc/bash.bashrc.
  3. ~/.bash_profile, 1-, .
  4. [edit], ~/.bash_logout.
  5. [edit] /etc/bash.bashrc, ~/.bashrc.
  6. "--norc" .
  7. "--rcfile" file Bash .
  8. Bourne shell csh startup [edit], "" csh. Bourne , csh.

POSIX 1003.2

Portability of POSIX 1003.2




Bash –posix set -o posix Bash POSIX 1003.2. , , Bourne, . Bash , Bourne. :

  1. .
  2. $ (). POSIX 1003.2.
  3. .
  4. .
  5. .
  6. - Bash "if".
  7. .
  8. .
  9. .
  10. ""- Coprocesses.

Bash "readline" (Emacs). Vi- "set -o vi".

Expanding Braces with Wildcards




, , - , "C". . . . , Bourne .

, , . , . Bash .

, , "eval" , :

  • $ start = 1 ;
  • end = 10 $ echo { $ start .. $ end } # - {1..10};
  • $ eval echo { $ start .. $ end } # , : 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.

""

Syntactic Aspects of the Bash Language




ASCII, «editor», . , , , - vi Emacs, UNIX / Linux, , «», TextEdit UltraEdit Microsoft Windows.

Bash , «#! / Bin / bash», , . , , «bash».

-, , , «#!». , « / bin», , :

  • « / usr / bin », « / usr / local / bin ».

«#» . «#» . . , , , , « \ ». , «;».

«», , . Bash «», , , , .

, , , . , , . , . "match" Bash , , .

Interactive launch




, - , . , , , , , , . , , , . , , .

, , , , , . , Apple Macintosh Mac OS X , Terminal, Utility «».

Linux , GNOME KDE, , «» « → ». , :

  • $ echo;
  • $SHELL /bin/bash.

Bash, , , PATH, «which», «bash»:

  • $ echo $SHELL /bin/tcsh $ which bash /bin/bash $ bash bash-2.03$.

, , , , , . . , , Invio/Enter. , «;». , « \ ».

,

Apiks, double and back quotes




, , . , Bash .

. , . , , , . , , , - . .

, , «» Bash . , , , . , , , « \ » . , , .

, , . , Bash , .

Command Examples




, , ASCII:

  • $ pwd ;
  • echo $SHELL ;
  • hostaname /home/marco /bin/bash aquilante $ echo \ > $SHELL /bin/bash.

«script.sh », , :

  • echo -n "Oggi e' il " 2 date +%d/%m/%Y.

, , :

  • $ bash script.sh Oggi e' il 10/6/2011.

, Bash:

  • $ cat script.sh | bash Oggi e' il 10/6/2011.

Bash- «#!». , , , Bash :

  • $ cat script.sh #!/bin/bash echo -n "Oggi e' il " date +%d/%m/%Y $ chmod 755 script.sh $ ls -l script.sh -rwxr-xr-x 1 marco users 49 18 Apr 23:58 script.sh $ ./script.sh Oggi e' il 10/6/2011.

, , «script.sh», , « ./ » . , , , . Bash.

Bash

. , . , , .

"yaml" "json", . Bash , .

Bash - , . . , , . , Bash, .

Bash -, Linux . , , Azure , Azure, Azure Portal Azure Documentation.

, Bash. CLI, , , Bash, CLI 2.0.

Bash. !




All Articles