low-order seven bits

Hi and thx in advance :slight_smile:

I have to transfert files between a UNIX server and a Network Appliance Filer and i have problem with accent characters on filename.

On unix side accent are interpreted as follow
ls -l unix* | cat -v
-rwxr--r-- 1 a067842 admDE 0 Sep 24 16:33 unix_M-^J.txt
and are well interpreted using samba (i.e. a windows workstation show the correct character).

If i transfert the file (using rsync with archive mode) on the filer and access it using NFS I see the same filename
ls -l unix* | cat -v
-rwxr--r-- 1 root other 0 Sep 24 16:38 unix_M-^J.txt

but It's not well interpreted by DOT (Data OnTap which is the Netapp filer Operating System) when accessed from a windows workstation (i.e. a windows workstation doesn't show the correct character)

If I create the file with the wanted filename from windows workstation on the filer it appears accessed from NFS like:
ls unix*.txt | cat -v
unix_M-i.txt

So I understand that M-i and M-^J shown by the cat -v command are differents :smiley: , I will have to scan all my data and replace one character by the oher one to make the migration a success.
Problem how can I do this??? The cat man page indicates that characters starting with a "M-" string are non printable and correspond to the "low-order seven bits", is there a way to manipulate this ASCII characters using sed or something else?
Sorry for the long post, hope it's roughly clear (Huummhhh, not sure).

You can employ tr to change control characters to something printable. Filenames with embedded control characters cause trouble.

try something like this to get rid of control characters.

for file in /path/*
do
        tmpfile=`basename "$file"`
        tmpfile=`echo "$tmpfile" | tr -s '[:cntrl:]'  'z' `
        mv "$file"  /path/"$tmpfile"
done

the -b option of ls gives the octal value for non printable characters, using the tr command as indicated it's much more simple.
Thx.