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

КОМЕНТАРІ • 29

  • @amitlondhe3651
    @amitlondhe3651 2 роки тому +2

    Very good and clear explanation video. Thank you

  • @MrVisheshsingh
    @MrVisheshsingh 3 роки тому +2

    Thank you for sharing!

  • @jalandharbehera8109
    @jalandharbehera8109 3 роки тому +1

    Thank you so much sir.....I am so happy 🙏🙏🙏

    • @PedagogyV
      @PedagogyV  3 роки тому

      welcome..and stay happy :)

  • @sajinprasad8711
    @sajinprasad8711 2 роки тому +1

    Thanks bro

  • @narayanaswamy9596
    @narayanaswamy9596 2 роки тому

    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..

  • @adammohammed4959
    @adammohammed4959 Рік тому

    how do I grep a file for lines containing the shell and display the output

  • @RajRoy-wb1iz
    @RajRoy-wb1iz 3 роки тому +1

    Hi... How can we grep certain numbers of line (say 10 lines) from a file and then print it in another file

    • @PedagogyV
      @PedagogyV  3 роки тому

      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.

  • @boggarapulokesh3224
    @boggarapulokesh3224 2 роки тому +2

    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

    • @PedagogyV
      @PedagogyV  2 роки тому

      stackoverflow.com/questions/373810/unix-command-to-find-lines-common-in-two-files
      here , is your answer

    • @boggarapulokesh3224
      @boggarapulokesh3224 2 роки тому

      @@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.

    • @PedagogyV
      @PedagogyV  2 роки тому

      @@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.

    • @boggarapulokesh3224
      @boggarapulokesh3224 2 роки тому

      @@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?

    • @PedagogyV
      @PedagogyV  2 роки тому

      @@boggarapulokesh3224 yes, that will be great . The link for telegram will be in description of video.

  • @Yogeshkumar-dc2cr
    @Yogeshkumar-dc2cr 3 роки тому +1

    how can i use grep -v in a file in foreach collection cmd

    • @PedagogyV
      @PedagogyV  3 роки тому

      sry , didn't get "foreach colleaction cmd"..could you elaborate ?

    • @Yogeshkumar-dc2cr
      @Yogeshkumar-dc2cr 3 роки тому

      @@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.

    • @PedagogyV
      @PedagogyV  3 роки тому

      @@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

  • @beastavinash4655
    @beastavinash4655 2 роки тому

    Bro do you have notes of this?

  • @shokhrukholimjonov5231
    @shokhrukholimjonov5231 Рік тому +1

    Thank you it was very beneficial but stop using ok to much

    • @PedagogyV
      @PedagogyV  Рік тому

      its stopped in future videos

  • @kunalmahajan9665
    @kunalmahajan9665 2 роки тому +1

    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

    • @PedagogyV
      @PedagogyV  2 роки тому +1

      Hi, we can use multipl grep..
      cat filename | grep Ram | grep name

  • @BoffkaBoffka
    @BoffkaBoffka Рік тому +1

    🙂Thankyou!!!👍