Hi geminishaa and welcome to LQ!
So very many times I see people try to write complex stuff all in one line.
As grail points out, the syntax can be complicated.
It does not need to be. You can write tests and nest your if tests within each other and have more easy to maintain, as well as readable code.
Further, those complex test lines do not match the requirement you cited.
You cited this:
Quote:
Originally Posted by geminishaa
I am having below requirement
if $test is internal ; SERVTYPE is assigned as a
if $test is external ; SERVTYPE is assigned as b
|
And I do not see how those lines correlate to satisfy these very simple requirements.
Quote:
Originally Posted by geminishaa
I can write this thing in if else statement but I want to do it this way.
|
I suggest that you first post how you've written it as an if-else statement to clarify exactly what you're trying to accomplish by optimizing the way the code is written.
I will end by reminding that one-line and concise is not always better.
Please use
[code][/code] tags to enclose code and output.
Please post any errors or output you're receiving with your attempts.
If you're running this within a script, add the line "set -xv" just prior to the point where you perform this test to get additional debug output.
If you're running this from the command line, you can also type "set -xv" into the command line, and then later type "set +xv" to disable the verbose output. You can also add a "set +xv" line within a script to do a similar reversing of the extra debug mode.