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

Defining filters and using head, tail, and wc - Linux Tutorial

From the course: Linux: Bash Shell and Scripts

Start my 1-month free trial

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…

Contents