์ฌ์ฉ๋ฐฉ๋ฒ
grep ๋ช ๋ น ๋ค์ ์ฌ๋ฌ ๋ฌธ์์ด, ํ์ผ ์ด๋ฆ, ํด๋น ๊ฒฝ๋ก๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์๋์ ๊ฐ๋ค
์์ ๋ฐ์ดํ(' ')๋ก ๋ฌถ๊ณ ํ์ดํ( | )๋ก ๊ตฌ๋ถํ๊ณ ํ์ดํ์์ ๋ฐฑ์ฌ๋์( \ ) ์ฌ์ฉํจ
grep 'abc\|def' fileName_or_filePath
์ต๊ทผ์ ๋ง์ด ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ -E ์ต์ ์ ์ฌ์ฉํจ
-E ์ต์ ์ ํ์ฅ ์ ๊ท ํํ์์ผ๋ก ์ฒ๋ฆฌํจ
grep -E 'abc|def' fileName_or_filePath
grep์ ํ์ฅ๋ฒ์ ์ธ egrep ๋ ๊ฐ๋ฅ
egrep 'abc|def' fileName_or_filePath
-e๋ฅผ ์ฌ๋ฌ๋ฒ ์ฌ์ฉ๋ ๊ฐ๋ฅ
grep -e abc -e def fileName_or_filePath
grep, grep -E ๋ฐ egrep์ ์ฐจ์ด์
- grep์ด egrep ๋ณด๋ค ์ค๋๋ ๋ฒ์ ์
- grep์ ํ๋์ ๋ฌธ์์ด์ ์ฐพ๊ณ , egrep์ ์ฌ๋ฌ๊ฐ์ ๋ฌธ์์ด์ ๋์์ ์ฐพ์ ์ ์์
- grep์์ ํ์ฉํ ์ ์๋ ๋ฉํ๋ฌธ์ ์ด์ธ์ ์ถ๊ฐ ์ ๊ทํํ์ ๋ฉํ๋ฌธ์๋ฅผ ์ง์ ํจ
* 2021.11.29 ์ถ๊ฐ๋ด์ฉ
- egrep ์์ ํ์ดํ๋ก ๊ตฌ๋ถํ ๋ ๋์ด์ฐ๊ธฐ ํ์ง๋ง๊ณ ๋ถ์ฌ์ ์ฌ์ฉ. ๋์ด ์ฐ๋ ์กฐํ๋์ง ์์์
์) ps -ef | egrep 'A|B|C|D'
grep๊ณผ egrep์ ๋ํ ์ต์ ์ด๋ ์ค๋ช ์ ๋์ค์ ๋ค์ ์์ฑ
์ฐธ๊ณ ์ฌ์ดํธ
How to Grep for Multiple Strings, Patterns or Words
Use grep to search for multiple patterns or words in a file by following examples in this guide. The grep tool is one of the most famous command-line tools.
phoenixnap.com
'๊ฐ๋ฐ ยท๊ณต๋ถ > Linux' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฆฌ๋ ์ค] USB ๋ถํ ๋์คํฌ ๋ง๋๋ ๋ฐฉ๋ฒ (0) | 2022.01.24 |
---|---|
[์ฉ์ด] ABRT(Automatic Bug Reporting Tool) (0) | 2022.01.05 |
[vi, vim ํธ์ง๊ธฐ] ๋ฌธ์์ด ๊ฒ์ (0) | 2021.10.19 |
[Linux] ์ ์คํฌ๋ฆฝํธ(Shell Script)๋? (0) | 2021.09.06 |
[JVM]์ฐ๋ถํฌ JDK, JRE ์ค์น / ์ค์ (0) | 2021.03.09 |