2012-02-05 2 views
0

파일이있어서 단어별로 정렬하고 특수 문자를 제거하고 싶습니다. grep 명령은 문자유닉스에서 grep 명령 사용

-b Display the block number at the beginning of each line. 
-c Display the number of matched lines. 
-h Display the matched lines, but do not display the filenames. 
-i Ignore case sensitivity. 
-l Display the filenames, but do not display the matched lines. 
-n Display the matched lines and their line numbers. 
-s Silent mode. 
-v Display all lines that do NOT match. 
-w Match whole word 

하지만 file sortremove the special character과 번호를 수행 할 grep 명령을 사용하는 방법 를 검색하는 데 사용됩니다.

+0

이것은 이해할 수있는 질문부터 먼 길이라고 생각합니다. – NPE

+0

sort 명령은이를 정렬하여 grep 또는 sed로 파이프하고 정규 표현식을 사용하여 문자를 제거합니다. –

+0

'단어를 따라 정렬'및 '특수 문자' –

답변

2

grep은 일치하는 텍스트를 찾기 위해 모든 파일을 검색합니다. 그것은 실제로 정렬되지 않으며 출력을 변경하고 변경하지 않습니다. 당신이 원하는 것은 sort 명령

sort <filename> 

및 텍스트를 조작하는 일반적인 도구 awk 명령 또는 나오지도 명령 중 하나에 전송 출력을 사용하는 아마.

sort <filename> | sed 's/REPLACE/NEW_TEXT/g' 

나는 상상할 수 있습니다.

2

다음 명령을 사용하십시오.

sort FILE | tr -d 'LIST OF SPECIAL CHARS' > NEW_FILE