Sponsored Content
Full Discussion: Problems if the else end if
Top Forums Shell Programming and Scripting Problems if the else end if Post 302916020 by Don Cragun on Friday 5th of September 2014 10:56:54 PM
Old 09-05-2014
Quote:
Originally Posted by junior-helper
If the problem is really only that... try replacing ==with -eq
== is for string comparison, -eq for arithmetic test
When comparing decimal numeric strings for equality, the results from:
Code:
[ "$n1" = "$n2" ]
       and
[ "$n1" -eq "$n2" ]

will always be identical as long as there aren't any "leading" zeros at the start of the string or after an initial minus sign

But when one of the two numbers can be an empty string (as in the example given by the OP), the first test will indicate that the two strings are not equal; but the second test will give you a syntax error in some shells (such as bash) because an empty string is not a numeric value. Other shells (such as ksh) will compare them as if the empty string is zero when using -eq.

Some shells accept == as a synonym for = as a test operator, but correctly writen applications will use =, not == in this form of test.
This User Gave Thanks to Don Cragun For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

'make' problems (compliation problems?)

I'm trying to compile and install both most recent version of 'make' and the most recent version of 'openssh' on my Sparc20. I've run into the following problems... and I don't know what they mean. Can someone please help me resolve these issues? I'm using the 'make' version that was... (5 Replies)
Discussion started by: xyyz
5 Replies

2. IP Networking

end-end packet delay?

following is the output from traceroute traceroute 10.1.11.6 traceroute to 10.1.11.6 (10.1.11.6), 30 hops max, 38 byte packets 1 10.129.1.250 (10.129.1.250) 20.618 ms 0.335 ms 0.271 ms 2 192.0.20.1 (192.0.20.1) 0.694 ms 4.660 ms 0.422 ms 3 192.0.40.1 (192.0.40.1) 0.972 ms 1.917 ms 0.873 ms... (4 Replies)
Discussion started by: yogesh_powar
4 Replies

3. IP Networking

Looking for an end-to-end network diagnostic utility...

I am looking for a utility (Windows/Linux/Mac) that will allow me to run some test packets across a customer's network (between their client & my server) to identify a list of (or at least a guess of) all protocols and significant network settings that could adversely effect my systems performance... (1 Reply)
Discussion started by: jjinno
1 Replies

4. Shell Programming and Scripting

Need UNIX shell scripting end to end information

Hi, I would like to learn shell scripting in UNIX. Can any one please give me the support and share the information/documents with me. If any documents please post it to aswanikumar_nimmagadda@yahoo.co.in Thanks in advance...!!! (3 Replies)
Discussion started by: aswani_n
3 Replies

5. Shell Programming and Scripting

Add end of char \n on end of file

Hi, I want to add \n as a EOF at the end of file if it does't exist in a single command. How to do this? when I use command echo "1\n" > a.txt and od -c a.txt 0000000 1 \n \n 0000003 How does it differentiate \n and eof in this case? Regards, Venkat (1 Reply)
Discussion started by: svenkatareddy
1 Replies

6. Shell Programming and Scripting

Use of Begin IF ,END IF END not working in the sql script

Hi I have written a script .The script runs properly if i write sql queries .But if i use PLSQL commands of BEGIN if end if , end ,then on running the script the comamds are getting printed on the prompt . Ex :temp.sql After connecting to the databse at the sql prompt i type... (1 Reply)
Discussion started by: isha_1
1 Replies

7. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

8. Solaris

Test program running taking much more time on high end server T5440 than low end server T5220

Hi all, I have written the following program and run on both T5440 and T5220 on same OS version. I found that T5540 server takes more time than T5220. Please find below the details. test1.cpp #include <iostream> #include <pthread.h> using namespace std; #define NUM_OF_THREADS 20... (17 Replies)
Discussion started by: sanjay_singh85
17 Replies
platform::shell(n)					       Tcl Bundled Packages						platform::shell(n)

__________________________________________________________________________________________________________________________________________________

NAME
platform::shell - System identification support code and utilities SYNOPSIS
package require platform::shell ?1.1.4? platform::shell::generic shell platform::shell::identify shell platform::shell::platform shell _________________________________________________________________ DESCRIPTION
The platform::shell package provides several utility commands useful for the identification of the architecture of a specific Tcl shell. This package allows the identification of the architecture of a specific Tcl shell different from the shell running the package. The only requirement is that the other shell (identified by its path), is actually executable on the current machine. While for most platform this means that the architecture of the interrogated shell is identical to the architecture of the running shell this is not generally true. A counter example are all platforms which have 32 and 64 bit variants and where a 64bit system is able to run 32bit code. For these running and interrogated shell may have different 32/64 bit settings and thus different identifiers. For applications like a code repository it is important to identify the architecture of the shell which will actually run the installed packages, versus the architecture of the shell running the repository software. COMMANDS
platform::shell::identify shell This command does the same identification as platform::identify, for the specified Tcl shell, in contrast to the running shell. platform::shell::generic shell This command does the same identification as platform::generic, for the specified Tcl shell, in contrast to the running shell. platform::shell::platform shell This command returns the contents of tcl_platform(platform) for the specified Tcl shell. KEYWORDS
operating system, cpu architecture, platform, architecture platform::shell 1.1.4 platform::shell(n)
All times are GMT -4. The time now is 11:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy