본문 바로가기
LEARN/OS

[UBUNTU] LINUX grep 명령어

by 아이엠제니 2024. 6. 3.

CLOUD: AWS EC2
OS: Ubuntu 22.04.4 LTS


 

 

 

`file.txt`에서 h 들어가는 라인 찾기


grep h file.txt

 

 

grep -c h file.txt

  • -c는 count

 

👉 총 라인 카운트

wc -l file.txt

 

 

 

`bbc.txt`에서 h 검색


grep h bbc.txt

 

👉 대소문자 구분없이 검색

grep -i h bbc.txt

 

👉 라인 카운트

grep -i -c h bbc.txt

 

 

 

텍스트 직접 검색


grep -i "good" bbc.txt

 

 

 

해당 문자가 포함되지 않은 라인만 출력


grep -v -i "th" bbc.txt

 

👉 count

grep -c -v -i "th" bbc.txt
grep -cvi "th" bbc.txt

 

 

 

참고
`Linux Command-Line 명령어 기초 배우기` - 인프런

 

 

 

300x250