I have a big problem with some non-standard characters while trying to copy (for the sake of backup) some files in AIX 6.1. What I need to do is have the backup archive with exactly same file names in order to able to restore the files and make it all works again.
I try to create ksh script which would take name by name (line by line) from csv file and copy them using cp to backup destination. After running the script I realised I have some files missing in new location. After some investigation I saw that missing files have some non-standard characters in their names in original directory (like long –, letters with accents etc.).
I have csv file with list of files to be copied, here example with long "–":
cat file_list.csv | grep pattern /path/to/file/some–file_with_pattern
when I try to copy this specific file with cp (both by script or by manually running cp):
cp /path/to/file/some–file_with_pattern /new/backup/path cp: /path/to/file/some–file_with_pattern: No such file or directory
when I display the file with ls:
ls /path/to/file | grep pattern some?file_with_pattern
So the AIX sees the file with "?" instead of "–" hence cp throws an error. When I use the wildcard (* or ?) to copy the file, then it is copied but has "?" instead of "–" in destination directory. When I put file name in ' ' or " " it is the same, "?" instead of "–" in destination directory. This doesn't satisfy my need, as when I restore file with different name ("?" instead of "–"), the application which uses it won't be able to refer to it.
I tried both ksh and sh (bash is unavailable on the server). I tried to play with locale (forcing UTF8 by setting LC_ALL="en_US.UTF-8"). I tried to play with Putty encoding settings. Still I am not able to refer to the files by their original names, hence cannot copy them keeping original name. Does anybody have any idea how to copy those files using shell commands?