Results 1 to 2 of 2
Hi Friendz,
I am new to the Linux Shell scripting.
Can anyone explain the below statement used in shell script
egrep 'FROM *RFC' $mibPath > /dev/null && { oldMib='yes'; }
...
- 03-19-2009 #1Just Joined!
- Join Date
- Jun 2008
- Location
- Chennai
- Posts
- 6
egrep 'FROM *RFC' $mibPath > /dev/null && { oldMib='yes'; }
Hi Friendz,
I am new to the Linux Shell scripting.
Can anyone explain the below statement used in shell script
egrep 'FROM *RFC' $mibPath > /dev/null && { oldMib='yes'; }
Thanks in advance
Raghu
- 04-16-2009 #2Just Joined!
- Join Date
- Oct 2007
- Posts
- 5
Assuming this is Bash:
As a whole this read as 'If the words FROM and RFC appear in all caps, with zero or more whitespace between them, in whatever file the variable mibPath is set to. Then set the the variable oldMib to yes.Code:egrep 'FROM *RFC' $mibPath > /dev/null && { oldMib='yes'; }
I would say this is bad writing style.
This part checks for the words FROM and RFC appear in all caps, with zero or more whitespace between them in whatever file $mibPath represents. The > /dev/null redirects the output of the command no nothing so you won't see it on the screen.Code:egrep 'FROM *RFC' $mibPath > /dev/null
The two ampersands mean logical AND (short-circuit operator). So if the return code of egrep is non-zero (which happens if there is no match), then the shell will not bother trying evaluate the part after the ampersands to see if it is also true. So basically, this is a convoluted way of writing an if-then statement.Code:&& { oldMib='yes'; }
-Kyle


Reply With Quote