Sponsored Content
Full Discussion: unary operator expected
Top Forums Shell Programming and Scripting unary operator expected Post 302295013 by Corona688 on Friday 6th of March 2009 10:16:55 AM
Old 03-06-2009
If $j has no value at all, the expression will be invalid because it will vanish entirely, making it look like just [ -j 50 ]. Wrap $j in double-quotes and it won't vanish, becoming [ "" -lt 50 ] , which still isn't altogether sensible -- comparing a blank string to an integer -- but at least has correct syntax.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

unary operator expected error

Hi I am doing a script like if then echo "table name dosent exist" exit fi the problem is if $table_name is null then i am getting the error Please help me Thanks in advance (2 Replies)
Discussion started by: ssuresh1999
2 Replies

2. UNIX for Dummies Questions & Answers

[: =: unary operator expected

HI, while running a script, I got the below mentioned error. /bin/sh: line10 : supportedMozillaVersion() { case "$*" in *rv:1.*) return 0;; *rv:.*) return 0;; *rv:*) return 1;; Mozilla\ 1.*) return 0;; Mozilla\ .*) return 0;; *) return 1;; esac } supportedFirefoxVersion() { case... (7 Replies)
Discussion started by: bhag281
7 Replies

3. Shell Programming and Scripting

unary operator expected

Im trying to fix my /etc/weekly that rotates various logs however it does them no matter what filesize they are and i want them to only do it if there file size exceeds 2M or something. So I'm playing with a script to get the filesize using a ls -l command which works and puts the value into a... (3 Replies)
Discussion started by: timgolding
3 Replies

4. Shell Programming and Scripting

line 5: [: -gt: unary operator expected

Hello all, :confused: I am not getting this error. Pls help me. ./construct_operon.sh: line 5: #!/bin/bash # Construct Operons using gene pairs. rm -rf operons_result lines=`awk 'END {print NR}' ecoli_operons` while ; do head -1 ecoli_operons | awk '{print $1"\n"$2}' > pattern ... (5 Replies)
Discussion started by: admax
5 Replies

5. UNIX for Dummies Questions & Answers

Error : -ne: unary operator expected

find . -name "*.*"|xargs grep WT:DBF_WL>> $F Wfexist=`cat $F|grep $i` echo $Wfexist if ; then echo $Wfexist echo "Workflow Exist" else touch $O chmod 777 $O echo $Wfexist echo $WfExist >> $O fi I am getting the error that -ne: unary operator expected in the line with red... (2 Replies)
Discussion started by: ritu.s
2 Replies

6. UNIX for Dummies Questions & Answers

Problem unary operator expected

I get the following error ./get_NE05: line 42: while do echo ${STRING_NAME} J=1 if ; then EXT=0$I else EXT=$I fi while do echo $I-$J #calculating last occurrence OCCURRENCE=`grep -io "${STRING_NAME}"... (3 Replies)
Discussion started by: f_o_555
3 Replies

7. Shell Programming and Scripting

unary operator expected

i=0 while Shell script reports an error "unary operator expected" pointing the above line. $i by default is 0 and holds integer value and $buf is also holding integer value. Please can some one let me know what is missing. Thanks. (1 Reply)
Discussion started by: sunrexstar
1 Replies

8. UNIX for Dummies Questions & Answers

: unary operator expected

Hiya all, Why do I get a :unary operator expected when I try to put a condition statement in my shell script (sh) like so and how to fix? if ; then echo "say hello" else echo "don't say hello" fi ? It seems if the script receives an argument it works but if I don't put an... (4 Replies)
Discussion started by: cyberfrog
4 Replies

9. UNIX for Dummies Questions & Answers

[: -gt: unary operator expected

Hi I have problem with my script. I dont now why but i don't change anything and script stop working. this is my code: #!/bin/sh for i in `ps -A | grep pocron.sh | grep -v grep | awk '{print $2}'` do COUNT=$((COUNT+1)) done ostatnie_wykonanie=`cat porader.log`... (1 Reply)
Discussion started by: fotex
1 Replies

10. Shell Programming and Scripting

Unary operator expected

In all my Googling, this usually happens when someone is comparing a variable, and that variable is unset. That doesn't appear to be the case for me... #!/bin/bash -x while read line do f=$(echo $line | tr -s ' ' | cut -d' ' -f 3) echo $f if then echo "This... (2 Replies)
Discussion started by: jnojr
2 Replies
POW(P)							     POSIX Programmer's Manual							    POW(P)

NAME
pow, powf, powl - power function SYNOPSIS
#include <math.h> double pow(double x, double y); float powf(float x, float y); long double powl(long double x, long double y); DESCRIPTION
These functions shall compute the value of x raised to the power y, x**y. If x is negative, the application shall ensure that y is an inte- ger value. An application wishing to check for error situations should set errno to zero and call feclearexcept(FE_ALL_EXCEPT) before calling these functions. On return, if errno is non-zero or fetestexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW) is non-zero, an error has occurred. RETURN VALUE
Upon successful completion, these functions shall return the value of x raised to the power y. For finite values of x < 0, and finite non-integer values of y, a domain error shall occur and either a NaN (if representable), or an implementation-defined value shall be returned. If the correct value would cause overflow, a range error shall occur and pow(), powf(), and powl() shall return +-HUGE_VAL, +-HUGE_VALF, and +-HUGE_VALL, respectively, with the same sign as the correct value of the function. If the correct value would cause underflow, and is not representable, a range error may occur, and either 0.0 (if supported), or an implementation-defined value shall be returned. If x or y is a NaN, a NaN shall be returned (unless specified elsewhere in this description). For any value of y (including NaN), if x is +1, 1.0 shall be returned. For any value of x (including NaN), if y is +-0, 1.0 shall be returned. For any odd integer value of y > 0, if x is +-0, +-0 shall be returned. For y > 0 and not an odd integer, if x is +-0, +0 shall be returned. If x is -1, and y is +-Inf, 1.0 shall be returned. For |x| < 1, if y is -Inf, +Inf shall be returned. For |x| > 1, if y is -Inf, +0 shall be returned. For |x| < 1, if y is +Inf, +0 shall be returned. For |x| > 1, if y is +Inf, +Inf shall be returned. For y an odd integer < 0, if x is -Inf, -0 shall be returned. For y < 0 and not an odd integer, if x is -Inf, +0 shall be returned. For y an odd integer > 0, if x is -Inf, -Inf shall be returned. For y > 0 and not an odd integer, if x is -Inf, +Inf shall be returned. For y < 0, if x is +Inf, +0 shall be returned. For y > 0, if x is +Inf, +Inf shall be returned. For y an odd integer < 0, if x is +-0, a pole error shall occur and +-HUGE_VAL, +-HUGE_VALF, and +-HUGE_VALL shall be returned for pow(), powf(), and powl(), respectively. For y < 0 and not an odd integer, if x is +-0, a pole error shall occur and HUGE_VAL, HUGE_VALF, and HUGE_VALL shall be returned for pow(), powf(), and powl(), respectively. If the correct value would cause underflow, and is representable, a range error may occur and the correct value shall be returned. ERRORS
These functions shall fail if: Domain Error The value of x is negative and y is a finite non-integer. If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [EDOM]. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the invalid floating-point exception shall be raised. Pole Error The value of x is zero and y is negative. If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [ERANGE]. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the divide-by-zero floating-point exception shall be raised. Range Error The result overflows. If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [ERANGE]. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the overflow floating-point exception shall be raised. These functions may fail if: Range Error The result underflows. If the integer expression (math_errhandling & MATH_ERRNO) is non-zero, then errno shall be set to [ERANGE]. If the integer expression (math_errhandling & MATH_ERREXCEPT) is non-zero, then the underflow floating-point exception shall be raised. The following sections are informative. EXAMPLES
None. APPLICATION USAGE
On error, the expressions (math_errhandling & MATH_ERRNO) and (math_errhandling & MATH_ERREXCEPT) are independent of each other, but at least one of them must be non-zero. RATIONALE
None. FUTURE DIRECTIONS
None. SEE ALSO
exp() , feclearexcept() , fetestexcept() , isnan() , the Base Definitions volume of IEEE Std 1003.1-2001, Section 4.18, Treatment of Error Conditions for Mathematical Functions, <math.h> COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technol- ogy -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . IEEE
/The Open Group 2003 POW(P)
All times are GMT -4. The time now is 08:08 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy