From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Solution: sed and AWK - Linux Tutorial
From the course: Linux Bash Shells and Scripts: Streamlining Tasks and Enhancing Workflows with Automation
Solution: sed and AWK
(bright music) - [Instructor] Let's look at solutions. So the first one had to do with processing the output of ls -s with set and so forth. So let's just take a look. There's the output of ls -s. And remember, if we pipe it, it'll be all in one column. So if we just did, for example, looking at a little bit of that. We'd get the total and we'd get those numbers. Let's look at a solution here. So it's just a set substituting from a space. the .* that's a regular expression. We haven't really talked about that much, but that essentially matches everything. And the dollar sign there is end of line. So that's going to match from the first base all the way to the end of the line, and it's going to replace that with nothing, //. And then we do another command. The semicolon there, we're going to delete line one, 1d. So if we do the ls -s |challenge4.sh. Oops, got to tell it where to get it. ./ we see all those fours. But quickly, let's look at another example. Let's look at the size of…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Defining filters and using head, tail, and wc3m 18s
-
(Locked)
The use of sed for powerful scripting5m 55s
-
(Locked)
Using AWK5m 22s
-
(Locked)
Positional parameters and curly braces for variables3m 40s
-
(Locked)
Shell parameter expansion3m 47s
-
(Locked)
Challenge: Looping and special variable operators1m 12s
-
(Locked)
Solution: Looping and special variable operators2m 23s
-
(Locked)
Challenge: sed and AWK1m 33s
-
(Locked)
Solution: sed and AWK3m 17s
-
-
-