If what you want is the 1st occurrence of the 1st character in field 4 in your file, the following should be a little more efficient than learnbash's suggestion:
awk -F'|' '!((c = substr($4,1,1)) in s) {s[c];print c}' file.txt
Otherwise, as shamrock said, we need to know what you mean by special, where in field 4 the special character can appear, and whether there can be more than one special character in field 4 in any line in your input file.
If you want to try the above awk script on a Solaris/SunOS system, use /usr/xpg4/bin/awk , /usr/xpg6/bin/awk , or nawk instead of awk .
awk -F'|' '
{ gsub(/[[:alnum:]]/, "", $4)
for(i = 1; i <= length($4); i++) {
if((c = substr($4, i, 1)) in s) continue
s[c]
printf("%s", c)
}
}
END { print ""
}' file.txt
seems to produce the unique set of non-numeric, non-alphabetic characters found in any position in field 4, producing the output in the format shown in message #5 in this thread: