Edit: @AllenZhang : I completely misunderstood your question by reading all nfs's in your question text as NTFS. However, the problem may still be related to NTFS in case that your nfs server is a Windows machine.
Some characters (including " * / : < > ? \ |
) are not allowed in file names in an NTFS partition. See Wikipedia Filename topic. Your problem is related to :
(the colon) character. You have to replace it with another character while copying.
As a demo, look at the following commands ran on an NTFS volume:
$ touch met_em.d03.2013-01-02_12:00:00.nc
touch: setting times of 'met_em.d03.2013-01-02_12:00:00.nc': No such file or directory
$ ls met_em.d03.2013-01-02_12:00:00.nc
ls: cannot access 'met_em.d03.2013-01-02_12:00:00.nc': No such file or directory
$ df .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdc1 312568640 264057464 48511176 85% /media/my_user/WD_300GB
$ blkid /dev/sdc1
/dev/sdc1: LABEL="WD_300GB" UUID="2E584CDC584CA505" TYPE="ntfs" PARTUUID="0015bef7-01"
$ sudo file -sL /dev/sdc1
/dev/sdc1: DOS/MBR boot sector, code offset 0x52+2, OEM-ID "NTFS ", sectors/cluster 8, Media descriptor 0xf8, sectors/track 63, heads 255, hidden sectors 63, dos < 4.0 BootSector (0x80), FAT (1Y bit by descriptor); NTFS, sectors/track 63, sectors 625137281, $MFT start cluster 786432, $MFTMirror start cluster 39071080, bytes/RecordSegment 2^(-1*246), clusters/index block 1, serial number 02e584cdc584ca505; containsMicrosoft Windows XP/VISTA bootloader NTLDR
Compare it with commands ran on an ext4 volume:
$ cd
$ touch met_em.d03.2013-01-02_12:00:00.nc
$ ls met_em.d03.2013-01-02_12:00:00.nc
met_em.d03.2013-01-02_12:00:00.nc
$ df .
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda 479670976 130386736 324848528 29% /home
$ blkid /dev/sda
/dev/sda: LABEL="home filesystem" UUID="91ee80e9-39bc-4521-bd48-46136744435b" TYPE="ext4"
$ sudo file -sL /dev/sda
/dev/sda: Linux rev 1.0 ext4 filesystem data, UUID=91ee80e9-39bc-4521-bd48-46136744435b, volume name "home filesystem" (needs journal recovery) (extents) (64bit) (large files) (huge files)
Going back to our NTFS volume:
$ touch $(echo met_em.d03.2013-01-02_12:00:00.nc | tr ':' '-')
$ ls
met_em.d03.2013-01-02_12-00-00.nc
So, if you want to copy some files from a directory to your NTFS (or nfs) volume, you can use this script, which will replace all colons (:
) with underscore (_
) characters, while copying:
#!/bin/bash
destination=./your_nfs_directory
for fn in "$@" ; do
newfn=$(basename "$fn")
cp -iv "$fn" "${destination}/${newfn//:/_}"
done
Don't forget to replace your real destination nfs directory in the line starting with destination=
. The script may be used like the following example:
./script_name ./2013*/*2013-01*
If your file names contain other non-allowed characters, you have to update it to take care of them also.
Note: I remounted the NTFS volume by hand. I suppose this skips some special mount options for Windows compatibility. This time I was able to create a file with a :
in it:
$ cd
$ sudo umount /dev/sdc1
$ mkdir /tmp/mountpoint
$ sudo mount /dev/sdc1 /tmp/mountpoint
$ cd /tmp/mountpoint
$ touch met_em.d03.2013-01-02_12:00:00.nc
$ ls
met_em.d03.2013-01-02_12:00:00.nc
touch A:B ; ls
– FedonKadifeli May 26 '19 at 14:48$ touch A:B; ls touch: cannot touch 'A:B': Input/output error
– Allen Zhang May 27 '19 at 3:44