I have file with greek or cyrillic characters.
It is not owned by me, but by the web server user (www).
I cannot use the shell as the web server user (www) or as root, but I've used a script (executed by the web server user) to set the modbits directory it is in to 777 and the file itself to 666.
I am not able to rename (or delete this) file. Even using the inode and using find
fails:
$ ls -i1
19120017 Idezbox - коробка.jpeg
$ find . -inum 19120017 -exec mv -i {} sane \;
mv: cannot move `./Idezbox - коробка.jpeg' to `sane': No such file or directory
Wildcards fail:
$ mv Idezbox*.jpeg sane
mv: cannot move `Idezbox - коробка.jpeg' to `sane': No such file or directory
The following Perl-script also fails:
find . -type f -print0 | \
perl -n0e '$new = $_; if($new =~ s/[^[:ascii:]]/x/g) {
print("Renaming $_ to $new\n");
rename($_, $new);
}'
It prints out:
Renaming Idezbox - коробка.jpeg to Idezbox - xxxxxxxxxxxxxx.jpeg
but the subsequent rename command has no effect.
However, note that there are 7 greek characters and 14 "x"-es.
Moving to the directory above and trying to delete "Junk":
$ rm -riv Junk
rm: descend into directory `Junk'? yes
rm: cannot remove `Junk/Idezbox - коробка.jpeg': No such file or directory
Some requested output:
$ mount | grep "on /ifi/asgard/k00"
asgard:/ifi/asgard/k00 on /ifi/asgard/k00 type nfs (rw,tcp,rsize=32768,wsize=32768,hard,intr,addr=xxx.xxx.xxx.xxx)
$ df .
Filesystem 1K-blocks Used Available Use% Mounted on
asgard:/ifi/asgard/k00
104857600 53201568 51656032 51% /ifi/asgard/k00
$ ls -al
total 88
drwxrwxrwx 2 www ifiweb 4096 2014-08-11 14:16 .
drwxrwsrwx 14 inf5270 inf5270 4096 2014-08-11 14:15 ..
-rw-rw-rw- 1 www ifiweb 35176 2012-04-14 13:38 Idezbox - коробка.jpeg
-rwxrw-r-- 1 gisle ifi-a 139 2014-08-11 14:15 perl-rename.sh
$ who ami i
gisle pts/122 2014-08-11 11:37 (safir.ifi.uio.no:13.0)
After having read through all comments and answers (thanks everybody!) I no longer think this is just about escaping or quoting the cyrillic characters. I need to look into the NFS angle.
Edit 2015-10-02:
The problem turned out to be NFS-related. Since the file was created directly on a NFS-mounted volume, which I accessed from another computer, nothing worked. Logging directly in on the server as root allowed a sysadmin (I am a mere user on this particular system and can't do this) to delete the file (using some standard method to escape the Greek characters). Kudos to G-Man for putting me on the right track (in a comment). If G-Man is still around and converts his comment into an answer, I'll accept it.
Best Answer
Your question indicates that this problem file is on an NFS-mounted filesystem, and nothing you do from your RHEL client successfully touches the file. This suggests that the problem has to do with the interface between your client and the NFS server. It may be necessary to login directly to the server to manipulate the file, or at least access it from a workstation running a different OS.