I have a problem with accessing files on an ext4 file system mounted as type NFS on a Linux server running CENTOS 6.5. I know the files exist on this file system because I can see them when I explicitly call them (e.g. with ls
, awk
, or cat
), but are not visible to some programs like rsync
or when piped from ls
into another program like grep
or awk
.
As an example to clarify, the following will return empty:
ls /mnt/seisvault2/data/sac/201402/20140203_220000_MAN/ | grep WCI\.BH1\.IU.10
While this shows me that the file actually exists:
ls /mnt/seisvault2/data/sac/201402/20140203_220000_MAN/WCI.BH1.IU.10
.
In the numerous directories where this is a problem, most files appear normally, without needing to be called explicitly as shown in the example.
Can anyone help me understand this problem?
As an example of why this is a problem, rsync -a copies the "missing" files on its first run, but for each subsequent run, it doesn't think the file is in the target directory, and so copies it again.
This problem seems to be resolved by a configuration setting under File Sharing / NFS. Originally, I had Operation Mode configured as "User Mode." However, it appears this should be "Kernel Mode."
Grep is using regular expressions, of which, '.' happens to be a special character. To demonstrate, imagine I make an empty and do the following:
Now, lets do some grepping! As expected,
ls | grep test
returns all the files in the directory:But lets say we just wanted the files with a '.' in them:
Huh, well that sucks. As mentioned above, '.' has special meaning in regular expressions (namely, match 1 character). How to solve this problem? Backslash comes to the rescue...as the... ESCAPANATOR
Note that I've put it in single quotes. This will work with double quotes as well -- in most situations (shell expansion can burn you on more complex regexes). If you need to do it without any quotes, you have to escape twice (once for bash, once for grep). It looks like this: