๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Develop/It ์ด๊ฒƒ์ €๊ฒƒ

[Linux] ์‹ค์‹œ๊ฐ„ ๋ชจ๋‹ˆํ„ฐ๋ง ๋ช…๋ น์–ด tail -f ๋ฐ ์‹ค์‹œ๊ฐ„ ๋ชจ๋‹ˆํ„ฐ๋ง ์ค‘ ํŠน์ • ๋‹จ์–ด ๊ฒ€์ƒ‰ grep

by _mingle 2022. 12. 9.
728x90

 

 

 

tail ๋ช…๋ น์–ด
//๊ธฐ๋ณธํ˜•ํƒœ
$ tail -f ํŒŒ์ผ์ด๋ฆ„.log

//์˜ˆ์‹œ
$ tail -f 2022-12-09.log
$ tail -20 2022-12-09.log

tail ๋ช…๋ น์–ด๋Š” ์ฃผ๋กœ ์‹ค์‹œ๊ฐ„ ๋ชจ๋‹ˆํ„ฐ๋งํ•  ๋•Œ ๋งŽ์ด ์”€.

tail -f : ํŒŒ์ผ์˜ ๋งˆ์ง€๋ง‰ 10๋ผ์ธ์„ ์‹ค์‹œ๊ฐ„์œผ๋กœ ์ถœ๋ ฅ

tail -n: n ๋งŒํผ์˜ ๋ผ์ธ ์ถœ๋ ฅ (n์€ ์ˆซ์ž์ž„)

 

grep ๋ช…๋ น์–ด

grep ๋ช…๋ น์–ด๋Š” ๋‹ค๋ฅธ ์šฉ๋„๋กœ๋„ ์“ฐ์ธ๋‹ค๊ณ  ํ•˜์ง€๋งŒ ๋‚œ ์ฃผ๋กœ tail๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•จ.

tail ๋กœ ์‹ค์‹œ๊ฐ„ ๋ชจ๋‹ˆํ„ฐ๋ง์„ ํ•  ๋•Œ ํŠน์ • ๋ฌธ์ž์—ด๋งŒ ๋ณด์—ฌ์•ผํ•  ๊ฒฝ์šฐ ์”€

//๊ธฐ๋ณธ ํ˜•ํƒœ
$ tail -f ํŒŒ์ผ๋ช….log | grep '๋ฌธ์ž์—ด'

//์˜ˆ์‹œ
$ tail -f 2022-12-09.log | grep 'g2b'
$ tail -f 2022-12-09.log | grep -w 'g2b'
$ tail -f 2022-12-09.log | grep -i 'g2b'
$ tail -f 2022-12-09.log | grep -wi 'g2b'

๊ทธ๋ƒฅ  grep๋งŒ ์“ฐ๋ฉด '๋ฌธ์ž์—ด'์ด ํฌํ•จ๋œ ๋ชจ๋“  ๋กœ๊ทธ ์ถœ๋ ฅ

grep -w : '๋ฌธ์ž์—ด'์ด ๋‹จ์–ดํ˜•ํƒœ๋กœ ๋˜์–ด์žˆ์„ ๋•Œ๋งŒ ์ถœ๋ ฅ

 grep -i:  '๋ฌธ์ž์—ด'์˜ ๋Œ€์†Œ๋ฌธ์ž๋ฅผ ๊ตฌ๋ถ„ํ•˜์ง€ ์•Š์Œ.

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€