3
Using if [ -f "file" ]
works on non-hidden files.
I'm trying to use it for a hidden file: if [ -f ".file" ]
and of course it returns false (even that .file
exists).
If I use if [ -f -a "file" ]
it returns true for all hidden files (that is, if 'any' file is hidden).
How can I check if a .someFile
exists (where 'someFile' is a hidden file)?
1I suggest:
help test
– Cyrus – 2018-04-21T12:25:10.500@Cyrus Ok, now I feel dumb. It's all there, listed green on black. Thanks! – bauerMusic – 2018-04-21T13:31:51.203
if [ -f "file" ]
will work fine for detecting hidden (but otherwise normal) files. If it's failing, you probably have something like a symbolic link to a file elsewhere; that's not a regular file, so the-f
test will return false. It has nothing to do with whether it's hidden or not. – Gordon Davisson – 2018-04-21T17:22:22.177