Computer/LINUX

Text Processing

알찬돌삐 2012. 8. 10. 16:12

 * sort
o sort 명령은 알파벳순으로 정렬을 시켜 출력한다.
o 기본적으로 숫자는 정렬되지 않는다. 숫자로 정렬하려면 다른 옵션을 사용해야 한다.
o sort 명령은 다음과 같은 옵션을 갖는다.
+ -d : Sorts in phone-directory order
+ -f : Sorts lowercase letters in the same manners as uppercase letters
+ -i : Ignotes any characters outside the ASCII range
+ -n : Sorts in numerical order instead of alphabetical
+ -r : Reverses the order of the output

* wc
o wc는 "word count"로 파일의 라인수, 워드수, 문자수를 출력한다

wc fileone
14 14 58 fileone

+ -c : Shows only the number of bytes or characters
+ -l : Shows only the number of lines
+ -w : Shows only the number of words

wc -w fileone
14 fileone

* fmt
o 지정된 너비로 출력 결과를 조정한다. 디폴트 width는 75 characters이다. -w 옵션을 통해 너비를 조정할 수 있다.

fmt fileone
seoul 1111 incheon 2222 pusan 3333 taegu 4444 daejeon 5555

fmt -w10 fileone
seoul
1111
incheon
2222
pusan
3333
taegu
4444
daejeon
5555

* 기본 옵션은 -w이다. 따라서 fmt -w10옵션과 fmt -10은 같은 결과를 보인다.

* tr
o tr(translate)는 문자셋을 다른 것으로 변경할 수 있다. 예를 들어 모든 소문자를 대문자로 바꾸려면

tr '[a-z]' [A-Z]' < filetwo
1111 NEWYORK
2222 LA
33333 BOSTON
4444 SAN
5555 WASHINGTON

cf) tr은 반드시 두개의 charcter sets만을 받아들이며 파일명은 사용하지 않는다. 따라서 반듣시 파일의 이름은 리다이렉트 입력기호를 사용하거나 파이프를 사용해야 한다.

o lower : All lowercase
o uppper : All uppercase characters
o print : All printable characters
o punct : Punctuation characters
o space : All white space
o alnum : Alpha characters and numbers
o digit : Numbers only
o cntrl : characters control
o alpha : Letters only
o graph : Printable characters but not white space

예를 들어 위에서 사용한 명령은 다음과 같이 내릴 수도 있다.

tr '[:lower:]' [:upper:]' < filetwo

Associated Utilities

* expand - Allows you to expand tab characters into spaces. The default number of spaces per tab is eight. but you can change that using the -t option
* file - Looks at an entry's signature and reports what type of file it is
* more - Display only one screen of output at a time
* split - Chops a single file into multiple files. The default is that a new file is created for every 1,000 lines of the original file. Using the -b option, you can avoid the 1,000 line splitting and specity a number of bytes to be put into each output file, or you use -l to specify a number of lines
* uniq - Examines entries in a file, comparing the current line with the one directly preceding it, to fild lines ar unique.
* vi - One of the greatest file editors.

이 글은 스프링노트에서 작성되었습니다.

.

'Computer > LINUX' 카테고리의 다른 글

vi tip  (0) 2012.08.10
UCC 를 위한 ffmpeg 설치  (0) 2012.08.10
SSH키를 이용한 RSYNC 백업법  (0) 2012.08.10
ssh 접속 공격 막기  (0) 2012.08.10
snort  (0) 2012.08.10