나는이 스크립트를 재미있게 명령 줄 유틸리티 인 bash로 작성하려고합니다.bash cmdline 토크 나이저/상대 빈도 막대 그래프 ... uniq 실패
# make the corpus
echo -e "this \t is a \n cor-pus; \nthis \t\nis \n\t sparta. \n" > corpus.txt
# munge, collapse whitespace, tokenize
cat corpus.txt | tr -d '[email protected]#$%^&*()-_=+' | tr '\t' ' ' | tr '\n' ' ' | tr -s ' ' | fmt -1 | uniq -c | sort -rn
은 내가
2 this
2 is
1 a
1 corpus
1 sparta
을 기대하지만 난
fmt -1
파이프 때
1 this
1 is
1 a
1 corpus
1 this
1 is
1 sparta
uniq
실패 얻을. 아마도 cat -e
으로 보지 못하는 문자가있을 것입니까? uniq
은 라인이 무엇이고 파일이 무엇인지 어떻게 결정합니까?
echo a a b | fmt -1 | uniq
내 스크립트에서도 ... | fmt -1 | uniq | ...
이 작동하지 않는 이유를 알고 있습니다.
덕분에
'tr '\ t' ''| tr '\ n' ''| tr -s ''''tr -s '\ t \ n' '' '로 쓸 수 있습니다. –