Sponsored Content
Full Discussion: Integer expression expected
Top Forums Shell Programming and Scripting Integer expression expected Post 302868757 by Scott on Monday 28th of October 2013 05:01:50 PM
Old 10-28-2013
-eq is used for numeric comparisons. = should be used to string comparisons. You should also quote variables in a test.

i.e.
Code:
if [ "$var" = EASY ]; then
  ...
fi

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Integer Expression Expected

Cannot figure out what the error is on line #10 I was trying to change my login prompt though I've success with that this shows up as well. Here's what I have (1 Reply)
Discussion started by: moonunit
1 Replies

2. Shell Programming and Scripting

:integer expression expected

Hi, echo $i until || do read NUM if && ; then printf "$FBOLD\nInvalid number, please enter valid backup number: $FREG" fi done Getting below error : ./import_location.sh: line 234: [: : integer expression expected ./import_location.sh: line 234: [: :... (5 Replies)
Discussion started by: milink
5 Replies

3. 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

4. UNIX for Dummies Questions & Answers

Integer Expression Expected!?!?

Ok, so I am beggining a script to factor the time difference from when a user logs on to current time but before I can even get too far I am getting the INTEGER EXPRESSION EXPECTED error. Can someone tell me what I am doing wrong? lhour=$(who | grep "$1" | cut -c30,31); lmin=$(who | grep "$1"... (1 Reply)
Discussion started by: losingit
1 Replies

5. 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

6. 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

7. Shell Programming and Scripting

Integer expression expected

hi Guys, when i run the below script its showing error "integer expression expected" script pasted below: #!/bin/sh for i in {1..$2} do if then scp server1:/root/file.2012-$1-0$i . else scp server1:/root/file.2012-$1-$i . fi done (8 Replies)
Discussion started by: ganga39
8 Replies

8. Shell Programming and Scripting

Integer expression expected

Hi, I have placed the script and running successfully on AIX However in Linux it throws integer expression expected Could some one please help me to fix this MaxThreshold4alert=`echo "$MaxCapacitycnt*(80/100)" |bc -l` echo $MaxThreshold4alert Error: 40.00000000000000000000: integer... (2 Replies)
Discussion started by: ajothi
2 Replies

9. Shell Programming and Scripting

Integer expression expected

Hi, I am getting the below error while comparing the month of a file to current month. I am using ls -lrth to get the month of that file and while using the if else condition i am getting the below error.. a1=`ls -lrth abc.txt | awk '{print substr($6,1,3)}'` This gives me the month from... (1 Reply)
Discussion started by: jaituteja
1 Replies

10. Shell Programming and Scripting

Integer expression expected

Hello , This is the piece of the code which is giving me trouble if ;then exit_proc "${SOURCEDIR}/${OUT_FILE} does not exists or not readable" 2 else word_count=`wc -l < ${SOURCEDIR}/$OUT_FILE` fi if ;then exit_proc "Word_count is more than allowed limit" 1 else... (6 Replies)
Discussion started by: Sri3001
6 Replies
magic(4)							   File Formats 							  magic(4)

NAME
magic - file command's magic number file SYNOPSIS
/etc/magic DESCRIPTION
The file(1) command identifies the type of a file using, among other tests, a test for whether the file begins with a certain magic number. The /etc/magic file, or a file specified as an option-argument to the -m or -M options of file(1), specifies what magic numbers are to be tested for, what message to print if a particular magic number is found, and additional information to extract from the file. Each line of the file specifies a position-sensitive test to perform. A test compares the data starting at a particular offset in the file with a 1-byte, 2-byte, 4-byte, or 8-byte numeric value or string. If the test succeeds, a message is printed. The line consists of the fol- lowing fields (separated by tabs): offset type value message offset A number specifying the offset, in bytes, into the file of the data which is to be tested. type The type of the data to be tested. The possible values are: byte, d1, dC A one-byte signed value. short, d2, dS A 2-byte signed value. long, d4, dI, dL, d A 4-byte signed value. llong, d8 An 8-byte signed value ubyte, u1, uC A one-byte unsigned value. ushort, u2, uS A 2-byte unsigned value. ulong, u4, uI, uL, u A 4-byte unsigned value. ullong, u8 An 8-byte unsigned value. string, s A string of bytes. All type specifiers, except for string and s, may be followed by a mask specifier of the form &number. If a mask specifier is given, the value is AND'ed with the number before any comparisons are done. The number is specified in C form. For instance, 13 is decimal, 013 is octal, and 0x13 is hexadecimal. value The value to be compared with the value from the file. If the type is numeric, this value is specified in C form. If it is a string, it is specified as a C string with the usual escapes permitted (for instance, for NEWLINE). Numeric values may be preceded by a character indicating the operation to be performed, as follows: = The value from the file must equal the specified value. < The value from the file must be less than the specified value. > The value from the file must be greater than the specified value. & All the bits in the specified value must be set in the value from the file. ^ At least one of the bits in the specified value must not be set in the value from the file. x Any value will match. If the character is omitted, it is assumed to be "=". For comparison of numeric values, the sign and size of both the value in the file and the value from the value field of the magic entry will match that of the corresponding type field. If there is a non-zero mask (&) in the type field, the compar- ison will be unsigned. For string values, the byte string from the file must match the specified byte string. The byte string from the file which is matched is the same length as the specified byte string. If the value is a string, it can contain the following sequences: character The backslash-escape sequences \, a, , f, , , , v. octal Octal sequences that can be used to represent characters with specific coded values. An octal sequence consists of a backslash followed by the longest sequence of one, two, or three octal-digit characters(01234567). message The message to be printed if the comparison succeeds. If the string contains a printf(3C) format specification, the value from the file (with any specified masking performed) is printed using the message as the format string. Some file formats contain additional information which is to be printed along with the file type. A line which begins with the character ">" indicates additional tests and messages to be printed. If the test on the line preceding the first line with a ">" succeeds, the tests specified in all the subsequent lines beginning with ">" are performed, and the messages are printed if the tests succeed. The next line which does not begin with a ">" terminates this. FILES
/etc/magic SEE ALSO
file(1), file(1B), printf(3C) NOTES
In Solaris 9 and prior releases, the file utility may have performed unsigned comparisons for types byte, short, and long. Old user-defined magic files, which were specified with the -m option, will need modification of byte, short, and long entries to their corresponding unsigned types (ubyte, ushort, or ulong) for those entries for which all of the following are true: o The entry uses the "<" or the ">" operator. o The type field does not contain a non-zero mask. o The intention of the entry is to test unsigned values. For example, if the following entry is expected to match any non-zero, one-byte value from the file, including values for which the sign bit is on: #offset type value message 0 byte >0 this matches any non-zero value then that entry should be changed to: 0 ubyte >0 this matches any non-zero value In Solaris 7 through Solaris 9, when applying tests for magic file entries whose type field is the numeric type "short" or "long", the file utility in the x86 environment would switch the byte order of the numeric values read. Starting in Solaris 10, the byte order will not be switched on x86. A test for a numeric value whose byte order is identical in both little- and big-endian architectures may require two magic file entries, to ensure that the test correctly identifies files in both environments. For example, a magic file entry that will match on a big-endian system may look like this: 0 long 0xf00000ff extended accounting file Its corresponding magic file entry that will match the same value on a little-endian system would look like this: 0 long 0xff0000f0 extended accounting file BUGS
There should be more than one level of subtests, with the level indicated by the number of `>' at the beginning of the line. SunOS 5.10 6 Feb 2004 magic(4)
All times are GMT -4. The time now is 06:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy