`
If you find these tutorials useful, Please consider making a donation.

TheFrugalComputerLinuxLogo.png
TheFrugalComputerGuy.png
Linux Command Line 12
find, grep, regex







Linux Command Line (34) find pt1

We first add the "tree" command so we can get a better visual look at what our LCL directory looks like.

We use the "find" command to find files by file name

When we do not know complete file name we are looking for we look at how to use the find command with the wildcards asterisk, question mark, and brackets

We then look at ways of filtering our find results to show just the file names or directory names and we look a a couple of different ways to limit our find search to specific directories.





 






Linux Command Line (35) find pt2

We start by finding files modified less then 7 days ago and then files modified more than 7 days ago.

Then we find all the files modified within the last 60 minutes and then we find files modified with in a specific range (more than 3 days ago, but less then a week ago) and we see how to not search a specific directory by adding -not -path to our find

We then look at how to use the find command to file files larger than a specific size and then empty files

We see how to find files with a specific user and a specific group or file permission.

We then look at how to delete all the files found in a find result by adding -delete to the end of the find command

We end by taking a quick look at how the locate command works for an Ubuntu based Linux operating system.





 






Linux Command Line (36) grep

In the early days of Unix grep stood for Global Regular Expression Print

We use grep to find regular expressions (also known as regex) text strings in a file.

The entire line that contains the regular expression is returned.

Grep is case sensitive (that we can turn off with the -i option) and can return lines containing the regex as a word (with white-space characters on both sides of the regex)

We then add the -n option to grep show the line numbers our regex is found and we can also grep the inverse (meaning show all the lines in the file except the lines the regex is found on) by using the -v option.

We can grep the count the number of times our regex is found with the -c option

We also look at how to pipe text into grep with ls -lh | grep '2019'





 






Linux Command Line (37) Intro to RegEx pt1

Regular Expressions are also referred to as RegEx. A regular Expression is a string of text, that allows us to create patterns that help match, locate, and manage text. Regular Expressions are used in many programming languages and text editors sometimes having slight differences.

The period is a wildcard any single character. Adding the escape character (a backslash) before a period can make the period work as a period, and not a wildcard.

The caret symbol means the line of text will start with the character (or characters) following the caret symbol.

Brackets around a group of characters work as an or for a group of characters.

A caret inside the brackets, means NOT any of the characters inside the brackets.

A dollar sign (to the right of the text) means the line must end with the characters to the left of the dollar sign.





 






Linux Command Line (38) Intro to RegEx pt2

This is a continuation from the previous video...

We first add a a few lines to the grocerylist.txt file (from video 7).

Then we look at the how the asterisk, question mark, and plus sign wildcards work and we learn about extended regular expressions.

We then look at how to create an "or" regular expression and then grep our grep to "and" the grep regular expressions.

We use regular expressions to show only the upper case letters and numbers in the file

We then look at how to use the character classes with grep.