abc.txt 파일이 있습니다. 이 파일에는 29개의 레코드가 필요합니다.제거하다다음을 기반으로 하는 URL이 있는 일부 행http://163.172.47.140:55555/
예를 들어:
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
답변1
그리고sed
주문하다:
샘플 input.txt
:
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
sed -i '/http:\/\/163\.172\.47\.140:55555\//d' input.txt
-i
- 파일 편집제자리에d
- 특정 패턴과 일치하는 기록 삭제
최종 input.txt
콘텐츠:
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
답변2
grep -vF 'http://163.172.47.140:55555/' input
-vF str
- 모든 라인은 포함되지 않습니다스테르
답변3
입력 파일
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
다음 명령은 "가 포함된 행을 삭제합니다.http://163.172.47.140:55555"
주문하다:
awk '!/http:\/\/163.172.47.140:55555/{print $0}' inputfile
산출
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323