그리프

grep
그리프
Grep example.png
의 예grep명령어
원저작자켄 톰슨[1][2]
개발자AT&T 벨 연구소
초기 릴리즈1973년 11월, 48년 전(1973년-11년)[1]
기입처C
운영 체제Unix, Unix-like, Plan 9, Inferno, OS-9, MSX-DOS, IBM i
플랫폼크로스 플랫폼
유형명령어
면허증.계획 9: MIT 라이선스

grep정규 표현과 일치하는 행을 일반 텍스트 데이터 세트 검색하기 위한 명령줄 유틸리티입니다.이 이름은 ed 명령어 g/re/p(정규 표현 및 일치하는 라인을 글로벌하게 검색)에서 유래했습니다.이 명령어 g/re/p는 같은 [3][4]효과를 발휘합니다. grep님은 원래 Unix 운영체제용으로 개발되었지만 나중에 모든 Unix 계열 시스템 및 OS-9 [5]등 일부 시스템에서 사용할 수 있습니다.

역사

이름이 붙기 전 grep은 특정 패턴을 검색하기 위해 Ken Thompson에 의해 작성된 개인 유틸리티였습니다.Doug McIlroy는 그것의 존재를 알지 못하면서 Thompson에게 그러한 프로그램을 만들어 달라고 부탁했다.Thompson은 이러한 유틸리티에 대해 하룻밤 사이에 생각해 보겠다고 대답하면서 실제로 버그를 수정하고 약 1시간 동안 개선했습니다.다음 날 그는 그 프로그램을 맥일로이에게 소개했고, 맥일로이는 그것이 바로 그가 원하던 것이라고 말했다.톰슨의 설명은 GREP가 하룻밤 [6]사이에 작성되었다는 믿음을 설명해 줄지도 모른다.

톰슨은 Lee E. McMahon연방주의 논문의 본문을 분석하여 개별 [7]논문의 저자를 결정하는 데 도움을 주기 위해 PDP-11 어셈블리 언어로 첫 번째 버전을 작성했다.Ed text editor(Thompson도 작성)는 정규 표현을 지원하지만 많은 양의 텍스트에서는 사용할 수 없었기 때문에 Thompson은 이 코드를 독립 실행형 [1]도구로 발췌했습니다.그는 ed 명령어 g/re/p가 지정된 [8][9]패턴에 일치하는 모든 행을 인쇄하기 때문에 이 이름을 선택했습니다. grep버전 4 Unix에 처음 포함되어 있습니다.McIlroy는 "일반적으로 프로토타입 소프트웨어 로 인용된다"고 언급하며,grepUnix에서 Thompson의 [10]도구 철학을 "복귀할 수 없을 정도로 주입"했습니다.

사용 예

다음 예시는 의 출력을 나타내고 있습니다.grep명령어에 다른 인수가 다릅니다.

$ grep root /etc/passwd root:/x:0:root:/bin/passwd $ grep -n root /etc/passwd 1:root:x:0:root:/bin/passwd 12:d:x:11:0:root/nologin/bin:roots $gin grep:g:ger:gen/bin grep.

실장

다양한grep구현은 많은 운영 체제 및 소프트웨어 개발 [11]환경에서 사용할 수 있습니다.초기 모델 포함egrep그리고.fgrep버전 [10]7 Unix에서 도입되었습니다."egrep" variant는 Ken Thompson의 최초 정규 표현 [12]구현 후 Alfred Aho에 의해 추가된 확장 정규 표현 구문을 지원합니다."fgrep배리언트는 Aho-Corasick 문자열 매칭알고리즘을 [13]사용하여 고정 문자열 목록을 검색합니다.이러한 변종의 바이너리는 대부분의 최신 시스템에서 유지되며, 일반적으로 다음과 같이 링크됩니다.grep단, 이러한 바이너리 사용은 다음 명령어를 사용하기 위해 권장되지 않습니다.-E그리고.-F명령줄 스위치grep대신.[14]

다른 명령어에는 검색 도구(일반적으로 정규 표현식 일치에 의존하는 도구)임을 나타내는 "grep"라는 단어가 포함되어 있습니다.예를 들어 이 유틸리티는 지정된 정규 [15]표현과 이름이 일치하는 프로세스를 표시합니다.

Perl 프로그래밍 언어에서 grep는 특정 [16]속성을 만족시키는 목록 내의 요소를 찾는 내장 함수의 이름입니다.고차 함수는 일반적으로 다음과 같이 명명됩니다.filter또는where다른 언어로.

pcregrep명령어는 의 구현입니다.grepPerl 정규 표현 [17]구문을 사용합니다.의 GNU 버전에서도 동일한 기능을 호출할 수 있습니다.grep와 함께-P플래그를 [18]설정합니다.

의 포트grep(예를 들어 CygwinGnuWin32 내)는 Microsoft Windows에서도 실행됩니다.Windows 의 일부 버전에서는, 다음과 같은 기능이 있습니다.qgrep또는findstr명령어를 [19]입력합니다.

A grep명령어는 ASCII의 MSX-DOS2 Tools for MSX-DOS 버전2에도 포함되어 있습니다.[20]

grep, egrepfgrep 명령도 IBM i 운영시스템[21]이식되어 있습니다.

소프트웨어 Adobe InDesign은 검색/변경 대화상자[23] "GREP" 탭에 GREP 기능(2007년 [22]이후)을 갖추고 있으며 InDesign[24] CS4에서 패러그래프[25] 스타일 "GREP 스타일"로 도입되었습니다.

agrep

agrep(대략 grep)은 텍스트가 검색 [26]패턴에 거의 일치하는 경우에도 일치합니다.

다음 호출에서는 파일 myfile에서 넷마스크를 찾을 수 있을 뿐만 아니라 두 개 이하의 치환을 지정하면 파일 myfile에서 파생될 수 있는 다른 단어도 찾을 수 있습니다.

agrep - 2 netmasks myfile

이 예에서는 가장 가까운 일치, 즉 가장 적은 치환을 가진 일치 목록을 먼저 생성합니다.명령어 플래그 B는 다음을 의미합니다.

agrep - B netmasks myfile

동사로서의 사용

2003년 12월, 옥스포드 영어사전 온라인은 "grep"의 초안을 명사와 동사 [27]둘 다로 추가했습니다.

일반적인 동사 사용법은 "You can't grep dead tree"라는 문구입니다.즉, 다음과 같은 툴을 사용하여 디지털 미디어를 통해 보다 쉽게 검색할 수 있습니다.grep하드 카피(즉, 죽은 나무로 만든 것, [28]이 문맥에서 종이용어)로 할 수 있는 것보다 더 많다.

「 」를 참조해 주세요.

레퍼런스

  1. ^ a b c Kernighan, Brian (1984). The Unix Programming Environment. Prentice Hall. pp. 102. ISBN 0-13-937681-X.
  2. ^ "grep은 내가 공개하기 전까지 꽤 오랫동안 나의 비공개 명령이었다." - Ken Thompson Archived 2015-05-26 at the Wayback Machine, By Benjamin Rualthanzauva, 2014년 2월 5일 발행, Medium
  3. ^ 호벤 외 1997년 9장
  4. ^ Raymond, Eric. "grep". Jargon File. Archived from the original on 2006-06-17. Retrieved 2006-06-29.
  5. ^ Paul S. Dayan (1992). The OS-9 Guru - 1 : The Facts. Galactic Industrial Limited. ISBN 0-9519228-0-7.
  6. ^ VCF East 2019 -- Brian Kernighan interviews Ken Thompson (video). YouTube. 6 May 2019. Archived from the original on 2021-12-11. (35분)
  7. ^ Computerphile, GREP의 유래, Brian Kernighan 인터뷰
  8. ^ "ed regexes". perl.plover.com. Archived from the original on 20 October 2017. Retrieved 24 April 2018.
  9. ^ "How Grep Got its Name". robots.thoughtbot.com. Archived from the original on 9 August 2017. Retrieved 24 April 2018.
  10. ^ a b McIlroy, M. D. (1987). A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 (PDF) (Technical report). CSTR. Bell Labs. 139. Archived (PDF) from the original on 2017-11-11.
  11. ^ Abou-Assaleh, Tony; Wei Ai (March 2004). Survey of Global Regular Expression Print (GREP) Tools (Technical report). Dalhousie University.
  12. ^ Hume, Andrew (1988). "A Tale of Two Greps". Software: Practice and Experience. 18 (11): 1063. doi:10.1002/spe.4380181105. S2CID 6395770.
  13. ^ Meurant, Gerard (12 Sep 1990). Algorithms and Complexity. Elsevier Science. p. 278. ISBN 9780080933917. Archived from the original on 4 March 2016. Retrieved 12 December 2015.
  14. ^ "grep". www.pubs.opengroup.org. The Open Group. Archived from the original on 28 November 2015. Retrieved 12 December 2015.
  15. ^ "pgrep(1)". www.linux.die.net. Archived from the original on 22 December 2015. Retrieved 12 December 2015.
  16. ^ "grep". www.perldoc.perl.org. Archived from the original on 7 December 2015. Retrieved 12 December 2015.
  17. ^ "pcregrep man page". www.pcre.org. University of Cambridge. Archived from the original on 23 December 2015. Retrieved 12 December 2015.
  18. ^ "grep(1)". www.linux.die.net. Archived from the original on 10 December 2015. Retrieved 12 December 2015.
  19. ^ Spalding, George (2000). Windows 2000 administration. Network professional's library. Osborne/McGraw-Hill. pp. 634. ISBN 978-0-07-882582-8. Retrieved 2010-12-10. QGREP.EXE[:] A similar tool to grep in UNIX, this tool can be used to search for a text string
  20. ^ "MSX-DOS2 Tools User's Manual by ASCII Corporation".
  21. ^ IBM. "IBM System i Version 7.2 Programming Qshell" (PDF). Retrieved 2020-09-05.
  22. ^ "Review: Adobe InDesign CS3 - CreativePro.com". creativepro.com. 20 April 2007. Archived from the original on 5 January 2018. Retrieved 24 April 2018.
  23. ^ "InDesign Help: find/change". Archived from the original on 2016-08-28. Retrieved 2016-08-12.
  24. ^ "InDesign: GREP Styles (1) Setting text between parentheses in Italic". Archived from the original on 2017-09-24. Retrieved 2018-01-05.
  25. ^ "InDesign Help: GREP styles". Archived from the original on 2016-08-28. Retrieved 2016-08-12.
  26. ^ S. Lee Henry (June 1998). "Proper Searching". Sun Expert. pp. 35–26.
  27. ^ "New words list December 2003". Oxford English Dictionary. Retrieved 2021-12-06.
  28. ^ 전문용어 파일, 문서 "Documentation"
메모들
  • Alain Magloire (August 2000). Grep: Searching for a Pattern. Iuniverse Inc. ISBN 0-595-10039-2.
  • 흄, 앤드류 그레프 전쟁: 전략적인 검색 이니셔티브입니다.Peter Collinson 편집자, EUUG Spring 88 Conferences, 237~245쪽, 영국 Buntingford, 1988.유럽 UNIX 사용자 그룹.
  • Michael Hauben; et al. (April 1997). Netizens: On the History and Impact of Usenet and the Internet (Perspectives). Wiley-IEEE Computer Society Press. ISBN 978-0-8186-7706-9.

외부 링크