IT/WSL
[ubuntu] grep 명령어 정리
상짱
2024. 5. 24. 09:32
반응형
# grep "찾을문자" 파일명
grep ERROR control*.log
# 건수
grep ERROR control*.log | wc -l
# 첫 줄
grep ERROR control*.log | head -1
# 마지막 줄
grep ERROR control*.log | tail -1
# 앞 1줄 포함
grep -B1 ERROR control*.log
# 뒤 1줄 포함
grep -A1 ERROR control*.log
# 앞 1줄 포함, 첫 2줄
grep -B1 ERROR control*.log | head -2
# 중복제거 및 정렬
grep ERROR control*.log | uniq -c | sort
# 문자 제외
grep ERROR control*.log | uniq -c | sort | grep -v "제외시킬문자"
반응형