![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| "test: argument expected" error | mvalonso | UNIX for Dummies Questions & Answers | 7 | 10-17-2008 08:16 AM |
| test: argument expected | lalelle | Shell Programming and Scripting | 10 | 02-12-2008 04:24 AM |
| test: argument expected | unitipon | Shell Programming and Scripting | 7 | 05-12-2007 11:54 AM |
| test: argument expected | andy202 | Shell Programming and Scripting | 5 | 01-09-2007 08:06 AM |
| ERROR-> test: argument expected , what does it mean? | tan102938 | Shell Programming and Scripting | 4 | 09-21-2006 08:20 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Facing test: argument expected ERROR
Hi All,
When i run the below code : v_shortfield = "" if [ $v_shortfield = "" ] ; then echo "ravi" else echo "kumar" fi i am getting output as : sam.ksh[3]: test: argument expected kumar Why i am getting error test:argument expected and why i am not getting output as "ravi" How to check the value of a string, especially if it is empty. I am facing this problem in my project. Requesting for quick response. Regards, Ravi Kumar Garlapati |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Code:
if [ -z $v_shortfield ] ; then |
|
#3
|
|||
|
|||
|
Hi reborg,
What is the opposit for the below line : if [ -z $v_shortfield ] ; then i mean if [ $v_shortfield != "" ]; then how to write this in shell script ?? Please help me out. Regards, Ravi Kumar Garlapati Last edited by rkrgarlapati; 07-20-2006 at 05:23 AM. |
|
#4
|
||||
|
||||
|
This is your original script.
Code:
v_shortfield = "" if [ $v_shortfield = "" ] ; then echo "ravi" else echo "kumar" fi It should become Code:
v_shortfield="" if [ -z $v_shortfield ] ; then echo "ravi" else echo "kumar" fi |
|
#5
|
||||
|
||||
|
if [ ! -z $v_shortfield ]
or if [ -n $v_shortfield ] |
|
#6
|
|||
|
|||
|
How to use NOT EQUAL TO in Shell script
Hi reborg,
What is the opposit for the below line : if [ -z $v_shortfield ] ; then i mean if [ $v_shortfield != "" ]; then my second question is how to use Logical OR operator for Strings values ? how to write this in shell script ?? Please help me out. Regards, Ravi Kumar Garlapati |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|