Re: Grab the value of the condition for if.
- From: Hongyi Zhao <hongyi.zhao@xxxxxxxxx>
- Date: Sun, 11 Jan 2009 20:04:44 +0800
On Sun, 11 Jan 2009 11:57:24 +0100, Janis Papanagnou
<janis_papanagnou@xxxxxxxxxxx> wrote:
Hongyi Zhao wrote:
Hi all,
Consider the following codes:
$ touch a.dat
$ if [ -f a.dat ] ; then echo a.dat exists. ; fi
In this example, the [ -f a.dat ] should have the value of _true_. My
issue is how can I grab the output value of this condition. Any hints
will be highly appreciated.
In the then/else branches assign constant values to a variable that you
can compare against later; e.g.
if [ -f a.dat ] ; then ov=T ; echo a.dat exists. ; else ov=F ; fi
...
case $ov in
T) ... ;;
F) ... ;;
esac
A further thought give me the following ideas:
In my mind, when the operator *-f* acts on the *a.dat*, then a inner
logical value, i.e., *T* or *F*, should be generated immediately. I
just want to trap this inner logical value directly instead of using a
roundabout way just as you've given above. Is this possible?
Regards,
--
..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
.
- Follow-Ups:
- Re: Grab the value of the condition for if.
- From: Andre Majorel
- Re: Grab the value of the condition for if.
- From: Maxwell Lol
- Re: Grab the value of the condition for if.
- From: Janis Papanagnou
- Re: Grab the value of the condition for if.
- References:
- Grab the value of the condition for if.
- From: Hongyi Zhao
- Re: Grab the value of the condition for if.
- From: Janis Papanagnou
- Grab the value of the condition for if.
- Prev by Date: Re: Grab the value of the condition for if.
- Next by Date: executing the results of a find/awk command
- Previous by thread: Re: Grab the value of the condition for if.
- Next by thread: Re: Grab the value of the condition for if.
- Index(es):
Relevant Pages
|