Linux/Mac Terminal Tutorial: The Grep Command - Search Files and Directories for Patterns of Text

Linux/Mac Terminal Tutorial: The Grep Command - Search Files and Directories for Patterns of Text

Corey Schafer

6 лет назад

348,746 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Younes Mdarhri Alaoui
Younes Mdarhri Alaoui - 05.05.2023 15:37

Excellent. Straight to the point. Concise and precise. Love it 🤩

Ответить
Shubho Das
Shubho Das - 18.03.2023 10:54

Brilliant, thank you!

Ответить
userx
userx - 12.03.2023 01:45

thank you very well done

Ответить
Solus
Solus - 13.02.2023 02:48

Wow mac sucks

Ответить
Kenchiken
Kenchiken - 19.10.2022 12:20

This video is definitely getting saved for future use

Ответить
Hana c
Hana c - 29.09.2022 19:27

Wonderfully explained

Ответить
Ilan Bar
Ilan Bar - 22.08.2022 09:45

where are you Corey. we are missing you man 💔

Ответить
Nikhil Cherian
Nikhil Cherian - 05.08.2022 21:23

Hey, thanks for the great tutorial, btw how did you create a custom zsh / bash session for theses tutorials?

Ответить
王振安
王振安 - 16.07.2022 07:39

great explanation

Ответить
Skinny Me
Skinny Me - 14.07.2022 19:17

Once I fell asleep on the keyboard typing grep arguments and it showed me the path to the 5th demension

Ответить
vasanthan vt
vasanthan vt - 06.07.2022 12:31

where are you Corey? Come back pls..

Ответить
Calisthenic Arts!!
Calisthenic Arts!! - 02.07.2022 08:08

How can I use grep to search multiple words or term, example. suppose i want to search for berries or cranberries in one line?

Ответить
Subs
Subs - 25.05.2022 17:07

How to i search for a Word like "John Williams" and i want to Eliminate the text below and after?

Ответить
Pär Törnell
Pär Törnell - 14.05.2022 18:06

Goos style for teaching, but im primarly looking for how to find files by filenames.

Ответить
Manfred Ramosch
Manfred Ramosch - 26.04.2022 22:57

When you wc -w some text of exactly 1000 words you get 1000 as a result. However when you split the same text with grep into individual words you get 1040 words because grep is splitting off the ‘s and ‘t from words like

• he’s
• there’s
• don’t
• won’t
• etc.

when you do

• cat input_file | grep -oE '\w{1,} '

Is there a way to make grep behave like wc, or do we have to use a different strategy for getting the right (desired) result?

Any ideas?

Ответить
mehdi nouira
mehdi nouira - 24.04.2022 15:33

how can i list show directories that do not start with 'a' and do not end with 'e'
please

Ответить
Rock
Rock - 14.04.2022 12:02

Please help. How can print the one that start with ''A'' and do not have ''B''

Ответить
Rener Gonçalves Lopes
Rener Gonçalves Lopes - 13.04.2022 15:30

You're the best! Thanks again.

Ответить
Tuaj Tuam Qhia Sawv Daws (Let Toua Teach You All)
Tuaj Tuam Qhia Sawv Daws (Let Toua Teach You All) - 13.04.2022 05:18

Very nice never bothered to learn it before but great video

Ответить
Dinesh Kumar
Dinesh Kumar - 31.03.2022 09:41

Hihifokp

Ответить
Dinesh Kumar
Dinesh Kumar - 31.03.2022 09:41

ahoiokhihiok

Ответить
Shriram balaji
Shriram balaji - 31.03.2022 07:35

Thank you....

Ответить
GlobalYoung
GlobalYoung - 28.03.2022 07:31

Thank you 😊

Ответить
Adam Puckey
Adam Puckey - 18.03.2022 12:57

Hello community. I am learning this for the first time and my return is just saying 'Binary file data.txt matches' - does anyone know what is different about my configuration?

Ответить
Shicheng Guo
Shicheng Guo - 13.03.2022 04:08

I'd like to show any files with 2 grep results among 100 files. How to make it?

for i in `ls *.txt`
do
if [[$(grep -n "pattern" $i) ==2 ]]; then
echo $i
wc -l $i
fi
done

Thanks.

Ответить
Kate Xie
Kate Xie - 28.02.2022 23:06

Thank you!! This tutorial is super helpful!!

Ответить
Apolo Du
Apolo Du - 19.02.2022 06:06

You've made learning these commands so easy, great job and thank you!

Ответить
Sabit Kondakçı
Sabit Kondakçı - 13.02.2022 17:55

it was rather helpful, great thanks for the contents.

Ответить
Johanna Varela
Johanna Varela - 18.01.2022 01:50

Quick question, I’m trying to locate negative numbers? How would I do that command?

Ответить
Asif Zaman
Asif Zaman - 15.01.2022 19:34

Command to search word on running/live log file?

Ответить
Quentin Guillot
Quentin Guillot - 13.01.2022 20:52

Hello Corey, when i enter the option --with-default-names. I have an error saying "Error : invalid option : --with-default-names". How i can fix it please ?

Ответить
TechnoMan Rahul
TechnoMan Rahul - 11.01.2022 20:51

Another awesome video from one of the greatest online tutors.. Hats off, corey. With lots of Love from India :)

Ответить
Martin Touko
Martin Touko - 08.01.2022 09:07

fantastic thanks . god bless man!!!

Ответить
Abhinav Salar
Abhinav Salar - 07.01.2022 19:23

I want to the following pattern using grep-
How can I find the word occurs at least 2 times with in a line?

Ответить
e500
e500 - 01.01.2022 19:38

THANK YOU SO MUCH

Ответить
Hackpens
Hackpens - 04.12.2021 17:53

Fantastic video. I learnt some great options today. Thank you very much!

Ответить
Tina Cole
Tina Cole - 05.11.2021 00:17

What is the -win for?

Ответить
Tina Cole
Tina Cole - 31.10.2021 23:50

for bash/command line how to match two different files and print results? I cannot find any example of this online

Ответить
User302
User302 - 14.10.2021 02:16

thx

Ответить
ValenX
ValenX - 13.10.2021 12:42

so what if I have a grep in a code that I wanna modify, and I want to grep something that the code is normally not made for.

ex. $word;

passthru("grep -i $word text.txt")

can I make this grep search for other files and results if I can substitude anything with $word (Tried -r ., -f file, --file=file, ./ )

Ответить
Yiyi Zhang
Yiyi Zhang - 06.09.2021 00:46

thank you so much for talking about the BSD grep and GNU grep!! i stuck there for so long ;-;

Ответить
Atul Chavan
Atul Chavan - 04.09.2021 09:32

Hey Corey, i have bunch of .gz files. And i want to do recursive search on them but it says "-r: option not supported"

zgrep -r "regex" ./

Ответить
Subham Raoniar
Subham Raoniar - 19.08.2021 15:06

Amazing video, exactly what I wanted

Ответить
Falke
Falke - 15.08.2021 00:41

I really like your shells theme! Its also a great tutorial!

Ответить
SAlEX Korsan
SAlEX Korsan - 09.08.2021 18:03

I need help,
I want to sort in bash file,
Example....

a="10"
b="100"
C="1000"

I want to sort this
$a $b $c

How to sort ?? Max value between this

Ответить