2013-06-25 6 views
0

저는 리눅스 명령입니다. 초보자입니다. 도움을 받으실 수 있습니다.파일 1에서 일치하는 내용을 인쇄하십시오. 파일 2의 행이 있습니다.

File 1: 
1:[email protected]:name1 
2:[email protected]:name2 
3:[email protected]:name3 
4:[email protected]:name4 
.... 

File 2: 
[email protected] 
[email protected] 
..... 

File 3: should print 
2:[email protected]:name2 
4:[email protected]:name4 
... 

난 당신이 그렙를 사용할 수 있습니다 패턴이 한 줄에 하나의 경우 파일 2.

답변

0

에 파일 한 경기에서 라인을 경기를 인쇄 할.

grep -w -F -f file2 file1 > file3 
+0

나는 당신이 아마'그렙 -w -f 파일 2 file1' (때문에 파일 2가 있던 경우에 [email protected], 다음 [email protected] 및 [email protected] 및 [email protected] 것 싶은 생각 시합). – SheetJS

+0

@Nirk 나는'-w' 또는'-F' 중 하나라고 생각했다. 나는 항상 잊는다. 감사. – squiguy

+0

당신은 둘 다 필요합니다 :'grep -w -F -f file2 file1> file3'. 여전히 가양 성일 수 있습니다. – jfs

관련 문제