root@calleva:~# echo "f" > file root@calleva:~# f=$(<file) root@calleva:~# echo "$f" f root@calleva:~# echo "$f" | tr -c '[:alpha:]' '_' f_root@calleva:~# echo "$f" | tr -c '[:alpha:]' -d tr: when translating with complemented character classes, string2 must map all characters in the domain to one root@calleva:~# echo "$f" | tr -c '[:alpha:]' '_' | tr -d '_' froot@calleva:~# echo "$f" | sed 's/[^a-z]//g' | tr -c '[:alpha:]' '_' f_root@calleva:~# So it appears that tr can do only one of -c and -d and not both at the same time?
And sed simply doesn't work?
tr -cd '[:alpha:]'works on FreeBSD.echo ba | tr ab -d. You should quit the habit of using options after non-option arguments. IMO it's a misdesign that some GNU utilities (apparently nottr) accept them.od -t x1ac, which shows them in hex, ASCII name, and escaped form.