Find Unique Characters in a File

前端 未结 22 2628
耶瑟儿~
耶瑟儿~ 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:07

    Quick and dirty solution using grep (assuming the file name is "file"):

    for char in a b c d e f g h i j k l m n o p q r s t u v w x y z; do 
        if [ ! -z "`grep -li $char file`" ]; then 
            echo -n $char; 
        fi; 
    done; 
    echo
    

    I could have made it a one-liner but just want to make it easier to read.

    (EDIT: forgot the -i switch to grep)

提交回复
热议问题