Simple sh script, simple error?

Simple sh script, simple error?

Post by Gary Rumbl » Wed, 18 Mar 1998 04:00:00




> Hello all,

> I have a simple bash shell script with this line:

> if [ $1 != "\n" ]; then
>   do something
> else
>   print an error
> fi

> But whenever I run it and the if is true (print the error) is also
> says [: !=: unary operator expected  ???

> != is a binary operator, requiring two arguments (says so in the bash
> man page.

> What am I missing??

> Paul

Quotes around the $1.

--
Gary Rumble                The opinions expressed are mine and don't

        http://ourworld.compuserve.com/homepages/grumble

 
 
 

Simple sh script, simple error?

Post by Paul Farb » Wed, 18 Mar 1998 04:00:00


Hello all,

I have a simple bash shell script with this line:

if [ $1 != "\n" ]; then
  do something
else
  print an error
fi

But whenever I run it and the if is true (print the error) is also
says [: !=: unary operator expected  ???

!= is a binary operator, requiring two arguments (says so in the bash
man page.

What am I missing??

Paul

 
 
 

1. Execute a sh script under perl and sh: sh script; perl script?

I can execute the following perl scripts under either shell or Perl
====

        if 0;
[perl scripts ...]
====
i.e.
sh script
perl script

How do I execute a sh script under either shell or Perl
simililar to what shown above?

Thanks.
--
Michael Wang

http://www.mindspring.com/~mwang    

2. newbie NFS question

3. simple shell script in sh

4. PAP ppp problem

5. a simple /bin/sh script question

6. lprm problem

7. Too simple a problem to see sh script

8. Intermittent failure - router or NIC problem?

9. syntax error with "cp" in simple file back up shell script

10. "Ambiguous redirect" error on a simple shell script

11. simple ksh tar script giving error?

12. Error in a (very simple) shell script - help...

13. Error is simple shell script