problem while comparing awk field variable with input variable entered using keyboard
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Please use [code][/code] tags around your code, to preserve formatting and to improve readability.
Shell variables are NOT awk variables! They may look the same at first glance, but awk uses a separate variable system with a slightly different syntax.
You have to import the bash variable into an awk variable before you can use it. (It's also possible by using careful quoting of the awk expression to allow shell expansion, but it's usually better to import it.
awk:syntax error near line 1
awk:bailing out error near line 1
can you please suggest the same above code in SOLARIS
Just a comment about awk and Solaris.
On Solaris 10 and older, /usr/bin/awk is a legacy binary that doesn't comply with standard awk. It is there only to maintain compatibility with old scripts that might still stay around.
For new scripts, you should always use /usr/bin/nawk (for new awk) instead. nawk is faster and complies with POSIX awk. For pure standard compliance, you might also use /usr/xpg4/bin/awk. If you are using Gnu specific extensions, you should instead run something like /usr/sfw/bin/gawk, /usr/local/bin/gawk, /opt/csw/bin/gawk, /usr/gnu/awk, or somewhere else depending on the Solaris release and optional packages possibly installed.