Placeholder Image

Subtitles section Play video

  • Hey, guys, what's up?

  • Welcome to experience Tech.

  • My name is Vineet and this is part two off grab tutorial and in this video will do a live demo covering all the options that were discussed in part one.

  • So for those of you have not seen my previous video, I highly recommend you to first go and watch my previous video and grab, wherein I have covered all the Turi aspect related to grab command in this video will do alive the more off all those options that were discussed in part one.

  • All right, so let's begin today's video.

  • All right, so here I am on my elementary Lennox machine.

  • Let me open up a terminal and let me increase the phone size.

  • Not those off.

  • You washed my previous video part one on grab knows their grip has tons off options available, and that is what makes it so powerful.

  • Now there are multiple ways to achieve a result in grab, so there's no one particular, best way or one way off doing things.

  • Their multiple options that are available and the same results can be achieved by different options.

  • Important thing to know Terry's that you learn by practice and you learn by your experience.

  • So the more you use grip, the better you become, innit?

  • No.

  • First, let's check the version off.

  • Grab that I'm currently running to do that type, grab and give a space dash Capital V for version.

  • So it says I'm running low grip version 2.16 Let's also quickly very find that I'm running the current version, which is available in the stable.

  • Repo off elementary Always to do that type apt gosh policy grip.

  • And as you can see, the candidate washing is 2.16 which is same as the install versions.

  • So I'm running the latest version, which is available in the rep Oh, off elementary overseas.

  • And as you can see, I'm currently under or test directory.

  • And under this directory, I have three text file, one of which is countries.

  • Don't t X T, and this file contains names off all the countries in the world along with their capital, so I'll use this file for our demonstration purpose.

  • Now let's start with the most basic usage of grip.

  • Let's check if the World Japan is available in countries don't t X T to do that type grip and in single courts, type Japan and give the file countries Don't t X T.

  • As you can see, grip has found a match, so we have the search tank.

  • Japan, along with its capital Tokyo grab, has printed the complete line.

  • Now the other input method that is available in Grab is instead of giving ah file to search, you can also provide a complete directory containing files in it.

  • So to do that type, grab dash are for a cursive.

  • And then let's give the same text.

  • Japan.

  • And then now you can either use period symbol, which is for the current directory.

  • Or you can also type in the complete path to the director.

  • So let's type home Xbox stick test directory.

  • No, this is the Korean directed that we're currently in Now.

  • If I press enter now, as you can see, Grip has found two matches.

  • The output line starts with defile where the match occurred and then the match text.

  • Now you can also provide input from standard in any command that can be run in terminal.

  • We can Piper True Grip, for example, I F conflict will give configuration off.

  • All the interface is that you computer has now You can also Piper true grip.

  • So if I type I have config, give a space and piper through grip and search for E T.

  • H zero.

  • Now this gives us only the line where 88 0 is present.

  • So this way you can pipe any command that can be run in a terminal.

  • You can Piper true grip.

  • You can basically use it as a filter for your other commands.

  • One another example.

  • You can also cat countries dor t x tree and then give grip Japon that will give us the same output.

  • Similarly, you can use TCP dump and pipe it true grap so that the output is displayed only from a particular I P address or foot particular website.

  • No.

  • Instead, off normal string, we can also provide regular expression or extended regular expression for our source text.

  • Let's take an example off regular expression.

  • So if I want to find out the names of all the countries that starts with the alphabet, J, I can just use the cat turd symbol and G and give countries dor t x t file as you can see we have the output off all the lines that starts with the alphabet G.

  • Similarly, you can use the dollar sign to find out all the lines that ends with a particular alphabet.

  • So let's find out all the lines that ends with the It's a bit E There you go.

  • Now, to find out all the lines that starts with the alphabet A, B or C, you can use the square brackets and type A, B, C and the single court and give countries Don't t x t.

  • I'm sorry.

  • I forgot to use the cantered symbol.

  • So let's you give the camera symbol All right, so we do not have any output.

  • This is because grab is case sensitive.

  • So to telegraph, to ignore case just to use the dash I option.

  • And now you have all those lines that starts with a B or C.

  • Now, instead of typing ABC, you can also use hyphen, which is the range indicator.

  • Anything between a to see will be matched, so you have the same output.

  • Now, if you want to invert this, that is if you want to find out all the lines that do not start with a B or C, you can use the square records, Vid countered.

  • So let's type the falling grab dash I for ignore case.

  • Then start on the court.

  • Scattered symbol for start of the lane that inside square record.

  • Use a carrot here, dash C and the square bracket and and the single court and provide the file.

  • Now we have the output off all those lines that do not start with a B or C.

  • All right.

  • Next, let's find out all the countries that starts with the alphabet F and has fourth character as the alphabet.

  • And to do that type Gramp Dash, I ignore case, then starts with the letter F and then fourth character, as in.

  • So for that, we can use the period symbol one to the fourth character to be end and provide the country's or t x t.

  • So, as you can see, we have the output.

  • France, which starts with the alphabet F and the fourth character, is the alphabet, and now you can also use the star symbol, which tell grips to use the preceding corrector zero or more times.

  • If I used your star, it will match all those lines that starts with F and has the corrector and innit?

  • So let's find that out.

  • As you can see, we have two output.

  • Finland and France.

  • Now let's try out some of the examples off extended regular expressions to use extended regular expression.

  • We use the option Dash Capital E.

  • Let's also use Ignore case and let's give a question mark.

  • This will tell.

  • Grab took out.

  • Put all those line that starts with G, and the next alphabet is optional.

  • So if the line do not have a still, it will print the output.

  • All right, so let's check that out.

  • As you can see, it has fined two lines that starts with the ah alphabet G and has the second alphabet as a.

  • And there's one Jordan, because the alphabet is optional.

  • No similarly instead, off question mark, you can use the plus symbol, which will tell grab to use the preceding character in this case one or more times.

  • So this time we will not have the output.

  • Jordan.

  • Similarly, we can tell grip how many times to use the alphabet using the curly braces.

  • So for Type One, which will tell Gramp to match a exactly one time if I Type two will not have any output, because Grab will search for any line that has J A.

  • So we don't do not have any input of it.

  • Curly braces.

  • You have three more options, comma at the end, which will telegram to match two or more times coma at the beginning, which will tell, Grab to match at at most two times, and you can also provide to number Separated by Kama.

  • Example.

  • To calm a five this will tell Grab to match preceding character two times, but not more than five times.

  • Night last.

  • We have the options.

  • Derek turns off options available with grip just so that we don't miss any off them.

  • And for the sake off understanding.

  • Let's go through all the options in alphabetical order.

  • All right, so first up is the capital E option, which will tell Grab to print that many number off leading lines.

  • So if a type dash a and give the number one, it will tell Grab to print one leading line from our match line.

  • The MASH line contains Japan, which is also sticks, and the output has one leading line from overmatched line.

  • Similarly, you have dash capital B, which is for trailing lines or previous line.

  • Next up is the capital C option which will print both one leading as well as one trailing lying.

  • Then you have dash lower case be option which will tell Grab to print the bite off.

  • Set off overmatched search text.

  • As you can see, the output starts with the bite offset 1641 This means that our matched text Japan is at 1641 bites from the starting off the file next up is dash lower case C option not this option will print the number off times the match occurred in the file.

  • As you can see, it has printed the output as one.

  • All right, Next is the capital e option that is for extended regular expression in that I have already covered.

  • Then you have lower case e option, which is to give multiple source strings.

  • So if I want to search for Japan and under the search string, let's say friends.

  • I can do that by using the dash e option So it has printed the output.

  • Now this can also be achieved using the extended regular expression step especially character, which is the pipe symbol.

  • And let's give the extended, vaguely expression option.

  • As you can see, we have deep same output, all right.

  • Next you have the capital F option that is to tell Grab that.

  • The source string does not contain any special character.

  • And it's a fixed string.

  • For example, if I do 192 dot no dart will not be replaced as any character if I use the dash F option.

  • All right, I have oven t X t file, which contains the I P address.

  • No, if I do not use the capital F option at reprint the falling output because it retake the dark character as especially correct, which is used to replace any character in it's place.

  • Now you can also use the backs last hotel grip to cancel the special meaning off dot operator on this will also give us the same result.

  • Next is the dash lower keys F option.

  • Now this is used to provide a file in place off a search string.

  • For example, here I have a file search filed, or T X T, which contains few search string now, using the dash.

  • Lower case F option.

  • I can provide this search file in place off a search string and, as you can see, grab matches each characters from our search files with the country's dirty extra five.

  • All right, Next is dash Capital G option.

  • This is the default option.

  • This tell script that D search text is a regular expression.

  • All right.

  • Next we have dash capital edge option.

  • The dash Capital s option will print the final aim along with the match line.

  • So if I give the Daschle orchid, which option will not drink the name off the file along with the output?

  • All right, This is important when you have given a directory to search.

  • Next, you have dash lower case I option, which is to ignore case and that we have already covered.

  • Next, you have dash capital.

  • L option.

  • This will print only the name of the files where the match did not take place.

  • And similarly, you have dash lower case l option.

  • This will print the names off those files Were match took place, nor the entire match line.

  • Next, you have lower keys.

  • M option along with a number, for example if I do Lower case M and a number two.

  • And let's change your search text too.

  • Any line that starts with the alphabet G and let's give countries Don t x t to search.

  • No, this will tell grip to stop after two matches.

  • All right, so as you can see, it has given us only to output.

  • If I give three, give us three direct next you have Lorca's an option that will print the line number were match took place along with the match line.

  • So you have Jamaica headline number 86 then Japan and 87 88.

  • You have the text, Jordan.

  • Next you have dash lower case O option.

  • This will tell.

  • Grab to print only the match part off the line and north entire line.

  • So if I do dash or now it's only print the match text, which is g All right.

  • Next you have dash lower keys are up, which is to Rikers, a directory that we have already covered.

  • And next you have dash uppercase t option, which is to give tabbed output.

  • So if I do grab dash D and let's see I want also want to print the line number and let's ignore the case and all those lines that starts with the alphabet G.

  • So, as you can see, we have our tabbed output for easy reading.

  • Next, you have lower keys V option, which is for involved match.

  • So let's give a regular expression, as any line that starts would be, too.

  • Who is it?

  • So they should only print line that do not start with B two said.

  • As you can see, we have the all put off all the lines which do not start with B two said.

  • Similarly, you have the dash w option.

  • This will tell grip to match only those lines, which contains our search text as a complete word, nor just a part off forward.

  • For example, if I provide any line that starts with J, it will not print any output because we don't have J as a single word.

  • So if I do Japan at repenting out book, all right.

  • Next is Dash Lorca's ex option that retail grab to match the entire line, not just a part off the line or not just a word.

  • So if I now do Japan, it will not give me any old port because Japan is not complete line.

  • We also have the word Tokyo in it.

  • All right, all right.

  • Finally, we have reached the end of this video.

  • I know it's been quite a long video, but believe me, guys, it's time well spent because grab will prove to be such a useful command in your arsenal off commands.

  • And every advanced Lennox user should have a good grip.

  • I'm sorry.

  • Good grip on the grip, command.

  • So I hope No, you're comfortable with grip command.

  • If you like this video, kindly present like button.

  • If you have any comment Oh, sedation, please.

  • Time.

  • That indica mint box and a huge shout out to all the subscribers off experience.

  • Tec channel.

  • Thank you, guys, and I'll see you next time.

Hey, guys, what's up?

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it