Linux Bash Shell Scripting: Complete Guide (incl. AWK & SED)

Linux Bash Shell Scripting: Complete Guide (incl. AWK & SED)

English | MP4 | AVC 1280×720 | AAC 44KHz 2ch | 8.5 Hours | 2.13 MB

Bash shell scripting tutorial, go from ZERO to HERO and let’s dance your bash programming skills

Welcome to linux bash shell scripting course. I’am Richard and I will be your instructor. I have great knowleadge about shell scripting as throughout my carrer I had been working for Fortune 50 company, where I apart from taking care of 200+ Solaris servers wrote many scripts for keeping live easy

What is covered?

  • Basics of scripting – no worry you don’t know anything about scripting by now
  • Sha-bang explanation – what it is and why the heck it is called sha-bang
  • Decision making
  • Regular expressions
  • Wildcards
  • For & While loops
  • Functions
  • Reading arguments using CASE structure
  • Getopt
  • Getopts
  • …and many more

And what about AWK? Yes, it is covered here! And what about SED? Also covered!

Why I have created this course?

Many years back, when I was starting as UNIX administrator, I had many ideas how to improve specific things using scripts. But, I couldn’t find any good resource, which would take me through all needed topic in one place. Somewhere I got great explanation about sha-bang while regular expressions for shell scripting were only mentioned. Somewhere was good explanation about decision making in if statement, but SED and AWK part was missing, and that use of SED and AWK was in my carrer really important. Basically I cannot imagine any single production script, where I wouldn’t used SED or AWK, because without them you are not able to create that “magic” in your script.

Many years later, I am here to share in one place what is really needed in order to create magic script. Not only how to create script, do some decision making in if statements, write functions, use arrays, but mainly how to combine everything including AWK and SED. I was creating this course in a way, which would help me a lot to create great scripts during start of my career. All needed things in one place.

What you’ll learn

  • Be able to create PRO looking script with parameters
  • Use functions in script
  • Read files line by line using while loop
  • Use math in scripts
  • Be able to decide if value of specific variable is a regular file or a directory
  • Store commands output into an array
  • Be able to do decision making based on match with regular expressions
  • Use SED and AWK to take your scripts into next level
Table of Contents

Linux commands
1 Introduction – welcome!
2 cp
3 mv
4 wc
5 grep
6 find
7 pwd
8 cd
9 ls
10 mkdir
11 touch
12 date
13 cat
14 rm + rmdir

Basics of scripting
15 Scripting – what it is all about
16 Math calculation
17 Math Calculation – showcase
18 Playing with $ arguments, arguments, arguments
19 More on arguments – playing with IFS and assigning arguments value to a variable
20 Redirection and Piping
21 Redirection and Piping – showcase
22 Exit status
23 Invoking the script
24 Sha-bang!
25 Using variables in scripts
26 Explicit definition – showcase
27 Read command
28 command substitution + time measurement

IF statement & Decision making
29 Explaining IF
30 Regular expressions – is there any reachable ip address
31 Filesystem related tests
32 Filesystem related tests – testing files permissions
33 && and – making IF statement shorter
34 Mathematical comparisons
35 String comparisons
36 String comparison – you are not root
37 Wildcards
38 Wildcards – making linux command badass
39 Wildcards – create backup script
40 Regular expressions

For loop
41 Explaining for loop
42 Add commands output into all .txt files
43 Looping through all script arguments $@ or $

While loop
44 Explaining while loop
45 Making own cat command with line numbering

CASE
46 Explaining case
47 Recheck users input
48 Creating script with parameters [-f file] [–file file] [-h] [–help]
49 (NEW) Manual Parsing vs Getopts vs Getopt
50 (NEW) Getopts – showcase script
51 (NEW) Getopt – showcase script

Arrays
52 Explaining Array
53 Array – storing output of command into array and making some fun with its items

Functions
54 Explaining Functions
55 Making addition in a function

AWK
56 Explaining AWK
57 if-else
58 for loop
59 Building script with AWK
60 AWK script PART 1 – reading arguments
61 AWK script PART 2 – was the location set
62 AWK script PART 3 – searching for specific extension
63 AWK script PART 4 – what about not existing extension
64 AWK script PART 5 – counting size of files using awk
65 AWK script PART 6 – setting largest and smallest file
66 AWK script PART 7 – printing statistics
67 print, BEGIN{}, {}, END{}
68 AWK script PART 8 – reading awk part from separate file
69 $1, $2, dollars everywhere
70 searching pattern
71 NF – number of fields
72 NR – number of records
73 FS – field separator
74 RS – record separator
75 variable assignment

SED
76 Explaining SED
77 Explaining s – substitute command
78 s – substitute command showcase
79 Building script with SED
80 SED script PART 1 – structure for reading arguments
81 SED script PART 2 – fixing spacetab issues
82 SED script PART 3 – printing lines which don’t have spacetab issues
83 SED script PART 4 – line numbering
84 SED script PART 5 – show spacestabs as a red background
85 SED script PART6 – show spacestabs also at the end of lines
86 SED script PART 7 – just to print it nicely
87 p – print command and -n option
88 a append i prepand
89 d – delete command
90 c – change command
91 q – quit command
92 e option Run multiple sed commands
93 i option Changing files for sure
94 e – perform shell commands

Sources
95 scripts