Welcome back to Linux fundamentals. This is the first course in the Linux Foundation Specialization. In our last module of this course we're going to think about searching and analyzing text. This can allow us to combine commands together to create automations and build new tools to help us get our jobs done quicker. So by the time you're done with this module I want you to be able to do many things. Including filter text files, redirect standard output, redirect standard input, redirect standard error, pipe commands together, and then lastly edit text files. All right, so in this first lesson we want to think about filtering text files. And what we mean by this is pulling out parts of text files to the command line. So the first command we're going to see is the cut command. And the cut command is going to cut out sections from each line of files and writes the results to standard output. There's several options here. The dash c says display only the record characters in the list. So I can say in the second example usage I say cut dash c 1 to 5 from /etc/passwd, which means only show the first five columns basically. The dash d designates a field delimiter. So in the example here dash d colon is going to say pull out fields 1 and 7, that's the dash f. It's going to display specific fields based on delimiter. So in the /etc/passwd we use a colon to separate fields and we're only going to cut out the first and seventh column here. And so you can quickly see that this becomes very powerful. Now what I didn't tell you here is by default the tab is the default delimiter in a file. But we use all kinds of things like the colon or space or commas lots of different delimiters to separate out data, okay? We've seen the grep command before. We're going to keep seeing it because it's very powerful. The grep command is going to use regular expressions to filter text from files. So I've some examples here, if I say grep daemon dot asterisk nologin from /etc/passwd. It's going to show me all the lines that include daemon as a word and nologin as a word with something zero more characters between it, okay? Now this doesn't mean it starts with daemon, it doesn't mean it ends with nologin. It just has to exist on each line, okay? Now we've got options. So, grep the carrot root says show me all the lines that start with word root from /etc/passwd. And then I included many options below. So the uppercase E lets you designate the pattern as what we call an extended regular expression and we'll talk about that in a minute. Dash i lets you ignore case on the search. Dash lowercase r searches a directory's contents for any subdirectory within the original directory tree and consecutively searches its contents as well. And dash v displays only text files records that do not contain the pattern match. So it's like a not true kind of thing. All right, so basic regular expressions. Essentially these are easier, right? So we'll start off with the asterisk. This represents multiple characters. I'm going to call that zero or more, okay? If we want to signify one character, we do that with a single dot. So in the first one that we have a dot asterisk which means one or more. So you can turn the zero or more into one or more without having the dot, okay? Now the next one is to represent specific characters by putting them in brackets. So in this example we have a, comma e, comma i, comma o, comma u, which means any of those five characters. We can also represent a range with a dash. So here we've got the A to Z in brackets. We can represent characters at the beginning of a line, we saw an example of that with the carrot. And we can represent them at the end with the dollar sign. And again we'll have more readings on these regular expressions. Extended regular expressions. Remember you could pass in the dash E to say you're going to use an extended regular expression. It allows more complex patterns than the basic. And mainly you're combining together possible options. So you can combine two or more possible characters with the pipe and you can you can designate additional sub expressions with parentheses, okay? We also have the word count command which displays the number of lines, words, or bytes in a file. So an example usage here is word count dash IL, the I here uppercase I displays the files line count, I guess it's a lower case L. And an uppercase L displays the byte count of the file's longest line. And we're going to pass in /proc/cpuinfo. There's also an option with a dash m that displays the file's character count. All right. A little review here, grep can use both basic regular expressions and extended regular expressions. The asterisk in basic regular expressions mean zero more characters. The dot means one character in basic regular expressions. All right, see in the next lesson.