24.07.2018 Views

Bash-Beginners-Guide

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Bash</strong> <strong>Guide</strong> for <strong>Beginners</strong><br />

Table of Contents<br />

Chapter 4. Regular expressions<br />

4.3.2. Character classes...................................................................................................................60<br />

4.4. Summary.........................................................................................................................................61<br />

4.5. Exercises.........................................................................................................................................61<br />

Chapter 5. The GNU sed stream editor..........................................................................................................62<br />

5.1. Introduction.....................................................................................................................................62<br />

5.1.1. What is sed?...........................................................................................................................62<br />

5.1.2. sed commands.......................................................................................................................62<br />

5.2. Interactive editing...........................................................................................................................63<br />

5.2.1. Printing lines containing a pattern.........................................................................................63<br />

5.2.2. Deleting lines of input containing a pattern..........................................................................64<br />

5.2.3. Ranges of lines......................................................................................................................64<br />

5.2.4. Find and replace with sed......................................................................................................65<br />

5.3. Non-interactive editing...................................................................................................................66<br />

5.3.1. Reading sed commands from a file.......................................................................................66<br />

5.3.2. Writing output files...............................................................................................................66<br />

5.4. Summary.........................................................................................................................................67<br />

5.5. Exercises.........................................................................................................................................68<br />

Chapter 6. The GNU awk programming language........................................................................................69<br />

6.1. Getting started with gawk...............................................................................................................69<br />

6.1.1. What is gawk?.......................................................................................................................69<br />

6.1.2. Gawk commands...................................................................................................................69<br />

6.2. The print program...........................................................................................................................70<br />

6.2.1. Printing selected fields..........................................................................................................70<br />

6.2.2. Formatting fields...................................................................................................................71<br />

6.2.3. The print command and regular expressions.........................................................................72<br />

6.2.4. Special patterns......................................................................................................................72<br />

6.2.5. Gawk scripts..........................................................................................................................73<br />

6.3. Gawk variables................................................................................................................................73<br />

6.3.1. The input field separator........................................................................................................73<br />

6.3.2. The output separators............................................................................................................74<br />

6.3.3. The number of records..........................................................................................................75<br />

6.3.4. User defined variables...........................................................................................................76<br />

6.3.5. More examples......................................................................................................................76<br />

6.3.6. The printf program................................................................................................................77<br />

6.4. Summary.........................................................................................................................................77<br />

6.5. Exercises.........................................................................................................................................77<br />

Chapter 7. Conditional statements..................................................................................................................79<br />

7.1. Introduction to if.............................................................................................................................79<br />

7.1.1. General..................................................................................................................................79<br />

7.1.2. Simple applications of if........................................................................................................82<br />

7.2. More advanced if usage..................................................................................................................84<br />

7.2.1. if/then/else constructs............................................................................................................84<br />

7.2.2. if/then/elif/else constructs......................................................................................................87<br />

7.2.3. Nested if statements...............................................................................................................88<br />

iii

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!