I am simply trying to copy files using cp -r /home/user/source/ /home/user/destination/
but it throws me the cp: cannot stat /source/filename.xxx
error for some of the files. When I searched for this error, I found some matching questions such as this and this which although have the same error thrown by cp
command but the reasons are different. Their solutions do not address my problem.
Upon looking closely, I saw that this error was being thrown only for files whose names contained Asian characters. For example,
cp: cannot stat /home/user/source/고정폭.collection
Does anyone have a solution for this? May be the default character encoding for my machine is not reading these file names.
EDIT 1: The output of my locale
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
EDIT 2:
Output of ls -l
in the source directory
ls: cannot access 고정폭.collection: No such file or directory
ls: cannot access 기존.collection: No such file or directory
ls: cannot access 모던.collection: No such file or directory
ls: cannot access 웹.collection: No such file or directory
ls: cannot access 재미.collection: No such file or directory
total 4
-????????? ? ? ? ? ? 웹.collection
-????????? ? ? ? ? ? 기존.collection
-????????? ? ? ? ? ? 모던.collection
-????????? ? ? ? ? ? 재미.collection
-????????? ? ? ? ? ? 고정폭.collection
-rw------- 1 root root 856 Jul 24 2007 PDF.collection
EDIT 3: File System and Mount information
Filesystem info on Source directory (output of stat -f -c %T .
)
ext2/ext3
Filesystem info on Destination directory (output of stat -f -c %T .
)
UNKNOWN (0x482b)
Selected Output of mount
/dev/sda5 on / type ext4 (rw,errors=remount-ro)
/dev/sdg1 on /media/user/osx86 type hfsplus (rw,nosuid,nodev,uhelper=udisks2)
/home/user/Desktop/debusb/Install OS X Mavericks.app/Contents/SharedSupport/InstallMacOSX.pkg/3.hfs on /mnt/osx type hfsplus (rw)
/home/user/Desktop/debusb/Install OS X Mavericks.app/Contents/SharedSupport/InstallMacOSX.pkg/base/3.hfs on /mnt/base type hfsplus (rw)
rsync -a source destination
(rsync also has some extra advantages, like smarter resuming and integrity checks via-c
). – Adam Katz Apr 3 '15 at 20:34cp
should be able to copy file names even if they aren't valid names in the current locale: it only needs to copy the bytes, it doesn't care what they mean. This could be a bug incp
, or in the filesystem, or the filesystem could be damaged. What is the exact error message fromcp
— you mention/home/user/source/
and then/source
? Is this the Ubuntu machine's disk or is another filesystem involved (a Windows partition, a network mount, …)? – Gilles 'SO- stop being evil' Apr 3 '15 at 22:54/home/user/source
and/source
confusion in the edited question. Also, the source is a Ubuntu machine disc withext4
filesystem and the destination is a flash drive withhfs+
filesystem. – Abhinav Apr 4 '15 at 0:11ls -la
– ctrl-alt-delor Apr 4 '15 at 9:56