# basic shell scripting question

**URL:** <https://community.unix.com/t/basic-shell-scripting-question/171548>\
**Category:** Shell Programming and Scripting\
**Created:** [May 27, 2007, 8:53pm UTC](https://community.unix.com/t/basic-shell-scripting-question/171548 "2007-05-27T20:53:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![convenientstore](https://community.unix.com/letter_avatar/convenientstore/32/5_5575768a8748004e209b776fc1b2916d.png) [@convenientstore](https://community.unix.com/u/convenientstore)\
**Post date:** [May 27, 2007, 8:53pm UTC](https://community.unix.com/t/basic-shell-scripting-question/171548/1 "2007-05-27T20:53:55Z")

</div>

If I did indeed grep something out of it, why woudln't $result show nothing?  
When I do $? , it does show success...

What is the proper syntax so that $result shows actual thing it's grepping out?

result=`(ssh $host tail -1 /something/somethingelse) | egrep -i "value" \>dev/null`

#echo $result  
#  
#echo $?  
#0

---

<div class="post-metadata">

**Author:** ![reborg](https://community.unix.com/user_avatar/community.unix.com/reborg/32/167_2.png) [@reborg](https://community.unix.com/u/reborg)\
**Post date:** [May 27, 2007, 9:34pm UTC](https://community.unix.com/t/basic-shell-scripting-question/171548/2 "2007-05-27T21:34:40Z")

</div>

result=`(ssh $host tail -1 /something/somethingelse) | egrep -i "value" \>dev/null`

Becuse that's what you told it to do.

---

<div class="post-metadata">

**Author:** ![convenientstore](https://community.unix.com/letter_avatar/convenientstore/32/5_5575768a8748004e209b776fc1b2916d.png) [@convenientstore](https://community.unix.com/u/convenientstore)\
**Post date:** [May 27, 2007, 9:42pm UTC](https://community.unix.com/t/basic-shell-scripting-question/171548/3 "2007-05-27T21:42:45Z")

</div>

u r abousteli rite.. that was stupid of me

---

<div class="post-metadata">

**Author:** ![convenientstore](https://community.unix.com/letter_avatar/convenientstore/32/5_5575768a8748004e209b776fc1b2916d.png) [@convenientstore](https://community.unix.com/u/convenientstore)\
**Post date:** [May 27, 2007, 10:21pm UTC](https://community.unix.com/t/basic-shell-scripting-question/171548/4 "2007-05-27T22:21:19Z")

</div>

I am trying to get below to be rite...

is this rite ?

in below.. (in dosomething), I cannot use elif.. since i have no condition..

can someone advise?

if something  
then  
somethingelse  
else  
dosomething \<----- especialli this one  
if something1  
then  
somethingelse1  
else  
somethingelse2  
fi  
fi
