Sponsored Content
Top Forums Shell Programming and Scripting integer expression expected error Post 302247129 by dark_knight on Wednesday 15th of October 2008 03:48:15 AM
Old 10-15-2008
integer expression expected error

I'm a beginner so I might make beginner mistakes.
I want to count the "#define" directives in every .C file
I get the following errors:

./lab1.sh: line 5: ndef: command not found
./lab1.sh: line 6: [: ndef: integer expression expected


Code:
#!/bin/sh

for x in *.[Cc]
do
        ndef = 'grep -c \#define $x'
        if [ ndef -ge 1 ]; then
                echo $x has $ndef define directives
        fi
done

Can you give me a hint of what's wrong?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

integer expression expected error crontab only

I created a bash script that ran fine for awhile on a nightly crontab but then started crashing with commands not found, so I added PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/home/homedir/scripts/myscriptdir export PATH and now I don't get those errors, but... (2 Replies)
Discussion started by: unclecameron
2 Replies

2. Shell Programming and Scripting

Display Error [: : integer expression expected

i have lunix 5.4 i make script to tack the export from database 11g by oracle user the oracle sheel is /bin/bash when run this script display this error ./daily_xport_prod: line 36: the daily_xport_prod script #! /bin/sh # ORACLE_HOME=/u01/appl/oracle/product/11.2.0/db_1 export... (8 Replies)
Discussion started by: m_salah
8 Replies

3. Shell Programming and Scripting

New to shellscripting error: ./emailnotifications.sh: line 43: [: FH: integer expression expected

Hi , I'm a beginner in unix shell scripting need help in rectifying an error Source file :test.txt with Header ------ ----- Trailer ex: FH201010250030170000000000000000 abc def jke abr ded etf FE2 I was validating whether the header begin... (2 Replies)
Discussion started by: dudd9
2 Replies

4. Shell Programming and Scripting

if script error: integer expression expected

Hi, i am making a simple program with a optional -t as the 3rd parameter. Submit course assignment -t dir In the script, i wrote: #!/bin/bash echo "this is course: ${1}" echo "this is assignment #: ${2}" echo "late? : ${3}" if then echo "this is late" fi but this gives me a :... (3 Replies)
Discussion started by: leonmerc
3 Replies

5. Shell Programming and Scripting

Integer expression expected: with regular expression

CA_RELEASE has a value of 6. I need to check if that this is a numeric value. if not error. source $CA_VERSION_DATA if * ] then echo "CA_RELESE $CA_RELEASE is invalid" exit -1 fi + source /etc/ncgl/ca_version_data ++ CA_PRODUCT_ID=samxts ++ CA_RELEASE=6 ++ CA_WEEK_NO=7 ++... (3 Replies)
Discussion started by: ketkee1985
3 Replies

6. Shell Programming and Scripting

Error: integer expression expected

root@server01 # df -h | grep /tmp | awk {'print $3}' 252M root@server01 # root@server01 # cat /usr/local/tmpchk.sh #!/bin/sh x=`df -h | grep /tmp | awk {'print $3}'` if ; then rm -fr /tmp/somefolder/ else echo "its small" (2 Replies)
Discussion started by: fed.linuxgossip
2 Replies

7. UNIX for Dummies Questions & Answers

Integer expression expected error in script

When i run the following code i get an error that says Integer expression expected! How do i fix this? #!/bin/bash if ;then echo "wrong" exit 1 fi if ;then for i in /dev;do if ;then echo $i ls -l fi (4 Replies)
Discussion started by: kotsos13
4 Replies

8. Shell Programming and Scripting

if condition error: integer expression expected

I am trying to run following condition with both variables having numeric values "1,2,3" if ;when i run it i get following error: $NEW_STATE: integer expression expected Please correct me where I'm doing wrong. I'm trying to check either New State is greater or Old state.... (0 Replies)
Discussion started by: kashif.live
0 Replies

9. Shell Programming and Scripting

Integer expression expected

Newb here echo "$yesterdaysclose" echo "$close" if ; then echo "stocks moving up" elif ; then echo "stock is moving down" else echo "no change" fi seems to evaluate the floating decimal correctly however returns ./shellscript1.sh: line 17: [: : integer expression expected... (3 Replies)
Discussion started by: harte
3 Replies

10. Shell Programming and Scripting

Getting error in bash script; expr $a + 1: integer expression expected

Hi, I am new to shell/bash script. I am trying to run below script #!/bin/bash a=0 b=10 if then echo "a is equal to be" else echo "a is not equal to be" fi MAX=10 while do echo $a a='expr $a + 1' done (1 Reply)
Discussion started by: Mallikgm
1 Replies
EXP(1.0)																  EXP(1.0)

EXP
exp - a multiple expession calculator. SYNOPSIS
exp [-vn0..4] [-o output-file] [input-file] DESCRIPTION
Input is an ascii format file including numeric expessions with variables. Input file can includes other input files thanks to an inclu- sion directive. exp reads the input files to write it as is in the output file, but the numeric expessions are replaced by their value. OPTIONS
-v verbose mode 0 : quiet mode 1 : messages mess(...) are printed 2 : few statistics 3 : all expressions are decomposed 4 : yacc messages -o output-file where exp writes (stdout by default). input-file where exp reads (stdin by default). EXP FORMAT FILES
Except the expessionsi and offline comments, the output file is identical to the flattened view of the input files whatever they are. The expession forms can be either [expessions] or {expessions}. The first form is for floating point expessions, the second one is for integer expessions. By default, the print format is respectively %7.3f and %4d (cf. sprintf(3)). Offline comments begins with // and ends at the beginning of the next line. Examples o [ 3.0 + 12.1] print 15.100 o { 3.0 + 12.1} print 15 It is possible to have more that one expession separated by ; (semi-column). All the expessions of a list are computed, but only the last one is printed. If the last expession is empty, exp do not print anything (see Examples section). Examples o [ 6. *2.0; 3.0 + 12.1 ] print 15.100 o [ 6. *2.0; 3.0 + 12.1; ] print nothing It is possible to have comments in expessions. A comment begins with # (diese) and ends to the carriage return. Comment in expression is not copied to the output file. Example o [ 3.0 + 12.1 # comment ] print 15.100 Expessions Expession is a multi-level numeric expession using numbers, variables, arithmetic operators and numeric functions. Examples o [ i=3.0; i*12.1] print 15.100 o {i=3} print 3 {i++} print 4 Arithmetic Operators The operators, in order of increasing priority, are + - Addition and subtraction. * / Multiplication and division. ++ -- post-incrementation of 1, post-decrementation of 1. ( ) Grouping = Variable affectation. The return value is the one affected. Boolean Operators > < respectively greater than and lower than def(variable) True whenever variable is defined yet ndef(variable) True whenever variable is not defined yet Variables Expession values may be stored in simple variables. There are three forms of variable name. First, they can begin with a letter followed by any number of letters, digits and underscores; second, they can begin with " (double quote) followed by any number of any char and ended by a "; Third they can begin with ' (quote) then a regular expression (see regex(7)) ended by '. exp is case sensitive. Examples o [ VAR_1=3.0; # first form "variable numero 2"=12.0; # second form ] print nothing o [ VAR_1 * "variable numero 2" ] print 15.100 When a variable appears in the right member of an affectation, exp uses its value. If it has never been defined, this causes a fatal error. If it appears the left member, the first time it is automatically created and its value is set, or its value is changed. Special variables float_fmt, integer_fmt and string_fmt special variables to redefine print format of floats, integers and strings. Defaults are %7.3f, %-8s and %4d. Those variables are the only variables with a non numerical value. Examples o [float_fmt = "%7.1f";] print nothing o [ 3.0 + 12.1] print 15.1 verbose is the variable passed in argument list, which can be modified by the program itself. Examples get details of expression calculation o [tmp = verbose; verbose = 3; ..expressions..; verbose = tmp;] Numeric functions Few numeric functions are available. The form is fun(args). The arguments take the form of a list of expessions, separated with a , (comma). The number of arguments depends on functions. It is possible to make a list of arguments with a regular expession (see regex(7)). Then all matching variable names are part of the list. min(args) max(args) The minimum (resp. maximum) value of its arguments. Examples o [min(3.0,12.1)] print 3.000 o [min('RW_ALU.*')] print min value of all variables begining by RW_ALU inf(step,val) sup(step,val) Two arguments. inf (resp. sup) function rounds the second argument (val) downwards (resp. upwards) to an integer number of the first argument (step). Examples o [step=0.3;value=1.6;inf(step,value)] print 1.500 Special functions and directives if(condition, expr1, expr2, ...) Calculates the condition if it is true (means greater than zero), the following expressions are all calculated. sort(args) rsort(args) sort (resp. reverse rsort) numerically all its arguments, each argument must be a variable, not directly a numeric expession. The return value is the sorted list of its arguments. message(args) writes its arguments to stdout using float_fmt, one argument per line. The form is : variable_name = value;, value is omitted if the variable has never been defined. Examples o [message('"'this is a message'"');] print this is a message o [a1b=0; a2b=1O; a3b=5; message(a*b);] print a1b = 0.000 a2b = 1O.000 a3b = 5.000 o [string_fmt=%6s; message(sort(a*b));] print a1b = 0.000 a3b = 5.000 a2b = 1O.000 #include "filename" Opens the file in argument then returns to the current file as soon as the new one is empty. EXAMPLES
Input file # this is a test file [ # few variables WITDH = 2; LENGTH = 25 ; ] this message is unchanged but all expresions are computed length_div_2 = [LENGTH/2] length_mul_2 = {LENGTH*2} result = [max ('leng.*')] Output file # this is a test file this message is unchanged but all expresions are computed length_div_2 = 12.500 length_mul_2 = 50 result = 12.500 AUTHOR
Written by Franck Wajsburt. SEE ALSO
Alliance .rds file uses exp to be generated. UPMC
/ASIM/LIP6 March 18, 2002 EXP(1.0)
All times are GMT -4. The time now is 09:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy