Find Unique Characters in a File

前端 未结 22 2336
耶瑟儿~
耶瑟儿~ 2021-02-04 03:30

I have a file with 450,000+ rows of entries. Each entry is about 7 characters in length. What I want to know is the unique characters of this file.

For instance, if my f

22条回答
  •  失恋的感觉
    2021-02-04 04:15

    Alternative solution using bash:

    sed "s/./\l\0\n/g" inputfile | sort -u | grep -vc ^$
    

    EDIT Sorry, I actually misread the question. The above code counts the unique characters. Just omitting the c switch at the end obviously does the trick but then, this solution has no real advantage to saua's (especially since he now uses the same sed pattern instead of explicit captures).

提交回复
热议问题