search lines in files and standard output | grep command in linux | family of grep commands
Вставка
- Опубліковано 12 січ 2021
- Hello guys , this video is about grep command in linux which is used to search and select lines having defined pattern or string from files and standard output . I had explained grep command in detail with examples . I also described the way of using grep command using pipe character in linux. Examples of grep command with pipe is also provided. At last , I defined and explained family of grep commands which includes grep command , fgrep command , egrep command and many more .
Topics covered in this video are :
- grep command in linux
- examples on grep command in linux
- grep command to select line from file in linux
- grep command to select line from standard output in linux
- grep command with pipe in linux
- family of grep commands in linux
- egrep command in linux
- fgrep command in linux
- difference between grep , egrep and fgrep command in linux
- grep command for case insensitive search in linux
- grep command with file option in linux
- grep command to pring not matched lines in linux
- grep command with standard output in linux
- regex using grep command
- searching multiple strings using grep command in linux
- grep command in detail
- grep command with files in linux
- grep command with standard output in linux
#grep #command #family #linux
_____________________________________________________
Support My Work On ...
Patreon :) / pedagogy
_____________________________________________________
Connect With Me On ...
Telegram :) t.me/vpedagogy
Instagram :) / vikramsingh100998
LinkdIn :) / vikram-singh-0b3712178
Facebook :) / vikramsingh100998
Very good and clear explanation video. Thank you
Thank you for sharing!
welcome :)
Thank you so much sir.....I am so happy 🙏🙏🙏
welcome..and stay happy :)
Thanks bro
Hii, your lectures are very simple and too good. In "20.0.RELEAESE" I want to grep only 20 from out of commented text. could you help me with this..
how do I grep a file for lines containing the shell and display the output
Hi... How can we grep certain numbers of line (say 10 lines) from a file and then print it in another file
for any set of lines you can use first sed command.
ex :- sed -n '2,12p' filename : it will print line 2 to line 12 of file . after that use grep within this range , i.e
sed -n '2,12p' file | grep word :- it will grep within this range of line and print them .
now , if you want to send the output to a file instead of printing , use redirect i.e
sed -n '2,12p' file | grep word > file2 :- it will redirect output to the file instead of printing.
hope , this will help :)
Not sure , why youtube is marking line over some of my comment , but take it as no line is marked on any comment.
Hey. I want to know whether i can compare two files line by line and print matching lines to a new file. I have tried using foreach loop. But didn't work. If possible let me know how i can do this using foreach loop. Thanks
stackoverflow.com/questions/373810/unix-command-to-find-lines-common-in-two-files
here , is your answer
@@PedagogyV No. That doesn't work. Comm - 12 works for small strings. Not for entire lines.
The content in 2 files that I'm comparing is like this. /shsvbs/clkc-r4738-sbs/sguahvs-refy_jegbsk/. Only bigger.
Each and every line in file1 is unique and has around 1000 lines. Same for the file2 as well. But some lines in both files match.
So comm - 12 doesn't do at all.
Have to use foreach or some other loop to compare 2 files line by line and output the matching lines to a 3rd file.
@@boggarapulokesh3224 Not sure why it is not working in your case. If possible , could you pls send these two file in telegram group, so that I can look into the problem and provide you some solution.
@@PedagogyV These are work files. So i can't send original files. But i can create and send sample files. What's your telegram in app name?
@@boggarapulokesh3224 yes, that will be great . The link for telegram will be in description of video.
how can i use grep -v in a file in foreach collection cmd
sry , didn't get "foreach colleaction cmd"..could you elaborate ?
@@PedagogyV I have 1 file in which I have to perform grep -v "pattern" 3 4 times
So I want to do via script. It's like if I source in outcomes without performing grep 3 4 times.
@@Yogeshkumar-dc2cr you can use shell scripts and loop 3.. 4 time ..
create an array first with index values like
arr=("pattern1" "pattern2" "pattern3")
for a in ${arr[@]}
do
grep -v ${a} dafile
done
in case it didn't work , please explain in telegram group
Bro do you have notes of this?
sadly...no
@@PedagogyV oke bro
Thank you it was very beneficial but stop using ok to much
its stopped in future videos
If two words are in same sentence its would be display only those sentence and I want to know if we can search two words at a time in file that should display the only sentence
For eg:-
What is your name?
My name is Ram
Ram is my name
Ram what are you doing
Question :- search ram and name and display only those sentence. Not all containing single words.
Output :-
My name is Ram
Ram is my name
Hi, we can use multipl grep..
cat filename | grep Ram | grep name
🙂Thankyou!!!👍