From the course: Linux: Bash Shell and Scripts
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Defining filters and using head, tail, and wc - Linux Tutorial
From the course: Linux: Bash Shell and Scripts
Defining filters and using head, tail, and wc
- [Narrator] Let's talk about programs that act as filters as we call them and eventually parameter expansion techniques in Bash. So in Linux in Bash a filter is a program that reads from standard in and writes to standard out. That means we can use it in the middle of a pipe. And filters usually do some sort of operation with their input and produce some sort of different output. They sort it, they pattern match it, they do arithmetic or something like that. It's these filters that give us quite a bit of capability in Bash greps to do lots of customization and reporting and so forth. So it's very common to use these sort of utilities in a Bash program. A couple simple ones are head and tail. Head prints the first n lines that it gets from standard in, and tail prints the last n lines that it got from standard in. So for example if we pipe ls minus l into head minus five, head will echo out on standard out the first five lines. If we pipe ls minus l into tail minus seven, tail will…
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
-
-
-
-
-
(Locked)
Defining filters and using head, tail, and wc5m 3s
-
(Locked)
Using sed and AWK for more powerful scripting13m 22s
-
(Locked)
Positional parameters and operators with braces10m 7s
-
(Locked)
Challenges: Looping, special variable operators, sed, and AWK1m 54s
-
(Locked)
Solutions: Looping, special variable operators, sed, and AWK2m 25s
-
(Locked)
-
-