This is not a homework. Actually I'm working in one project where I have one similar kind of file which is having list of special characters (removed from xml file) exactly in same format. Now I need to find out the records from that xml files which is having those special characters. I have done everything and now the pending item is only this. That's why I need help. Any help will be highly appreciated.
Thanks Yoda. I've tried both options but did not get the expected result.
When I'm using the 1st option within a function, it is showing the error "typeset bad option" and when I'm using the 2nd option with nawk, it is working, but I'm getting the same list of characters in output, not distinct character.
somehow the "typeset -A ARR" is not working in script, every time it is displaying the error message "typeset bad option(s)". Can anyone please help to find out the distinct character list?
Yoda's awk solution works for me. What do you mean you are not getting the expected result?
[root@Imperfecto_1 ~]# cat infile
a
b
c c
d d d g
e
f
[root@Imperfecto_1 ~]# awk '{ for(i=1;i<=NF;i++){a[$i]} } END{for (i in a) {print i}}' infile
a
b
c
d
e
f
g
And for typeset error, try typeset -a ARR
man typeset
-a Each name is an array variable (see Arrays above).
Hello All....1 quick question. If the file contains the character list in following way then the suggested awk command is working fine. Now if there is no space bewteen 2 characters in single line (for eg. CC instead of C C) then this command is not working. Any help if there is no space between 2 chars then how do I get the same result from this string?