티스토리 뷰

반응형

grep 는 원하는 문자를 검색하기 위한 명령입니다.

그런데 grep로 조회 시 아래와 같이 "grep --color=auto python" 가 추가되어 조회가 됩니다.

이것은 검색 결과에서 검색어에 색을 표시하기 위한 기능으로 자동 추가 됩니다.

$ ps -ef |grep python
future     851   518 99 14:24 ?        03:55:44 python main_single_proc.py
future     864   518 98 14:24 ?        03:55:37 python main_single_proc.py
future     876   518 98 14:24 ?        03:55:35 python main_single_proc.py
future     889   518 98 14:24 ?        03:55:23 python main_single_proc.py
future     902   518 98 14:24 ?        03:55:28 python main_single_proc.py
future     915   518 98 14:24 ?        03:55:21 python main_single_proc.py
future     928   518 98 14:24 ?        03:55:21 python main_single_proc.py
future     941   518 98 14:24 ?        03:55:30 python main_single_proc.py
future     954   518 98 14:24 ?        03:55:27 python main_single_proc.py
future     967   518 98 14:24 ?        03:55:33 python main_single_proc.py
future     985   520 98 18:09 pts/2    00:12:37 python main_single_proc.py
future     995   520 98 18:09 pts/2    00:12:33 python main_single_proc.py
future    1005   520 98 18:09 pts/2    00:12:32 python main_single_proc.py
future    1015   520 98 18:09 pts/2    00:12:28 python main_single_proc.py
future    1026   520 98 18:10 pts/2    00:11:49 python main_single_proc.py
future    1036   520 98 18:10 pts/2    00:11:48 python main_single_proc.py
future    1083   520  0 18:22 pts/2    00:00:00 grep --color=auto python

 

불필요한 항목을 제외하고 원하는 것만 조회 하려고 한다면 -v 옵션을 사용하여 제거할 수 있다.

$ ps -ef |grep python |grep -v "grep"
future     851   518 99 14:24 ?        03:57:29 python main_single_proc.py
future     864   518 98 14:24 ?        03:57:22 python main_single_proc.py
future     876   518 98 14:24 ?        03:57:20 python main_single_proc.py
future     889   518 98 14:24 ?        03:57:08 python main_single_proc.py
future     902   518 98 14:24 ?        03:57:12 python main_single_proc.py
future     915   518 98 14:24 ?        03:57:05 python main_single_proc.py
future     928   518 98 14:24 ?        03:57:06 python main_single_proc.py
future     941   518 98 14:24 ?        03:57:15 python main_single_proc.py
future     954   518 98 14:24 ?        03:57:12 python main_single_proc.py
future     967   518 98 14:24 ?        03:57:18 python main_single_proc.py
future     985   520 98 18:09 pts/2    00:14:22 python main_single_proc.py
future     995   520 98 18:09 pts/2    00:14:18 python main_single_proc.py
future    1005   520 98 18:09 pts/2    00:14:17 python main_single_proc.py
future    1015   520 98 18:09 pts/2    00:14:13 python main_single_proc.py
future    1026   520 98 18:10 pts/2    00:13:34 python main_single_proc.py
future    1036   520 98 18:10 pts/2    00:13:33 python main_single_proc.py

 

그래야 라인수를 조회하기 위한 wc 사용시 정확한 갯수를 확인할 수 있습니다.

$ ps -ef |grep python |grep -v "grep" | wc -l
16

'프로그램 > 우분투' 카테고리의 다른 글

우분투 사용자 생성(adduser)  (0) 2023.07.11
screen : Permission denied  (0) 2023.04.08
도커 백업 및 복구  (0) 2023.04.04
도커 컨테이너 기동시 서비스 자동 실행  (0) 2023.03.11
우분투 한글 설치  (0) 2020.03.02
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
글 보관함