[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU grep 2.4.2 on RedHat 7.0 i386
From: |
tt |
Subject: |
Re: GNU grep 2.4.2 on RedHat 7.0 i386 |
Date: |
27 Jul 2001 09:04:33 +0300 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
"ben catherall" <address@hidden> writes:
> Does grep follow symlinks properly?
> If i am in /etc/init.d and issue
> $ grep nobody ../passwd
> It will return file not found
> If i add an extra ../ in
> $ grep nobody ../../passwd
> It works.
>
> Is it supposed to work like that?
It's not a grep issue. Try 'ls ../passwd' and you'll get
the same error.
When use a symlink with 'cd', the symbolic path appears
in pwd by default, but .. will still point to the parent
of the real current directory, which in this case is /etc/rc.d
(as /etc/init.d is a link to /etc/rc.d/init.d).
The only commands (AFAIK) that can handle symbolic paths
in this case are shell built-ins pwd and cd,
and they have options -P and -L for choosing whether you want
physical or logical directory (compare "pwd", "pwd -L",
"pwd -P" and "/bin/pwd").
If you need to get to the logical parent with an external
command, you must do something like
grep nobody ${PWD%/*}/passwd
--
Tapani Tarvainen