Linux Command Line and Shell Scripting Bible, 3rd ed (2015)
817 pág.

Linux Command Line and Shell Scripting Bible, 3rd ed (2015)


DisciplinaGnu/linux19 materiais373 seguidores
Pré-visualização50 páginas
Plain text .................................................................................................537
Special characters .....................................................................................539
Anchor characters .....................................................................................540
Starting at the beginning ..................................................................540
Looking for the ending ......................................................................541
Combining anchors ...........................................................................542
The dot character ......................................................................................542
Character classes .......................................................................................543
Negating character classes .........................................................................546
Using ranges .............................................................................................546
Special character classes ............................................................................547
The asterisk ..............................................................................................548
Extended Regular Expressions .............................................................................549
The question mark .....................................................................................550
The plus sign.............................................................................................551
Using braces ..............................................................................................551
The pipe symbol ........................................................................................553
Grouping expressions .................................................................................553
Regular Expressions in Action .............................................................................554
Counting directory \ufb01 les .............................................................................554
Validating a phone number ........................................................................556
www.it-ebooks.info
xxvii
Contents
ftoc.indd 12/08/2014 Page xxvii
Parsing an e-mail address...........................................................................558
Summary ...........................................................................................................560
Chapter 21: Advanced sed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
Looking at Multiline Commands ..........................................................................561
Navigating the next command ....................................................................562
Using the single-line next command ..................................................562
Combining lines of text .....................................................................563
Navigating the multiline delete command ...................................................566
Navigating the multiline print command .....................................................567
Holding Space ....................................................................................................567
Negating a Command ..........................................................................................569
Changing the Flow .............................................................................................572
Branching .................................................................................................572
Testing ..................................................................................................... 574
Replacing via a Pattern ......................................................................................575
Using the ampersand .................................................................................576
Replacing individual words ........................................................................576
Placing sed Commands in Scripts.........................................................................577
Using wrappers ..........................................................................................578
Redirecting sed output ..............................................................................578
Creating sed Utilities..........................................................................................579
Spacing with double lines ..........................................................................579
Spacing \ufb01 les that may have blanks .............................................................580
Numbering lines in a \ufb01 le ............................................................................581
Printing last lines .....................................................................................582
Deleting lines............................................................................................584
Deleting consecutive blank lines ........................................................584
Deleting leading blank lines ..............................................................585
Deleting trailing blank lines ..............................................................586
Removing HTML tags .................................................................................586
Summary ...........................................................................................................588
Chapter 22: Advanced gawk  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
Using Variables ..................................................................................................591
Built-in variables .......................................................................................592
The \ufb01 eld and record separator variables ..............................................592
Data variables ...................................................................................595
User-de\ufb01 ned variables ...............................................................................598
Assigning variables in scripts ............................................................598
Assigning variables on the command line ...........................................599
Working with Arrays ..........................................................................................600
De\ufb01 ning array variables .............................................................................600
Iterating through array variables................................................................601
Deleting array variables .............................................................................602
www.it-ebooks.info
xxviii
Contents
ftoc.indd 12/08/2014 Page xxviii
Using Patterns ...................................................................................................602
Regular expressions ...................................................................................603
The matching operator ...............................................................................603
Mathematical expressions ..........................................................................604
Structured Commands ........................................................................................605
The if statement ........................................................................................605
The while statement ..................................................................................607
The do-while statement .............................................................................608
The for statement ......................................................................................609