[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Does [ -f FILE ] have a bug on testing a symlink ?
From: |
Stephane Chazelas |
Subject: |
Re: Does [ -f FILE ] have a bug on testing a symlink ? |
Date: |
Tue, 10 Feb 2015 21:25:04 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
2015-02-09 14:59:06 -0700, Bob Proulx:
[...]
> The idea is that symlinks should be completely transparent and
> invisible to most applications. The idea is that when normal things
> are run they don't realize they are using a symlink. Behavior would
> be exactly the same as if it were a regular file system link. That is
> what is happening in your test case. The symlink references an
> existing file, is a regular file and exists, therefore the status is
> true.
[...]
Note the discrepancy with "find" though.
With find, -type f will not match on symlinks to regular files
(unless you also use -L/-follow).
If you actually want to find regular files after resolving
symlinks, without resolving symlinks when walking down the
directory tree, that's where it becomes cumbersome.
POSIXly, you have to resort to the test command:
find . -exec test -f {} \; -print
With GNU find, you can use -xtype:
find . -xtype f
GNU find's -printf still doesn't give information on the target
of the symlink.
--
Stephane
- Does [ -f FILE ] have a bug on testing a symlink ?, Cheng Rk, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Chet Ramey, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Ken Irving, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Evan Gates, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Eric Blake, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Bob Proulx, 2015/02/09
- Re: Does [ -f FILE ] have a bug on testing a symlink ?,
Stephane Chazelas <=
- Re: Does [ -f FILE ] have a bug on testing a symlink ?, Andreas Schwab, 2015/02/09
Re: Does [ -f FILE ] have a bug on testing a symlink ?, Greg Wooledge, 2015/02/09
Re: Does [ -f FILE ] have a bug on testing a symlink ?, Geir Hauge, 2015/02/09