Greater than specific number


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Greater than specific number
# 1  
Old 11-12-2014
Greater than specific number

please let me know how to construct if then else by comparing two numbers if it is greater than 10000. I need to do some specific task executed.
can you help me out in shell scripting plz.
# 2  
Old 11-12-2014
Quote:
Originally Posted by ramkumar15
Please let me know how to construct if then else by comparing two numbers if it is greater than 10000. I need to do some specific task executed.
Can you help me out in shell scripting, please?

Code:
if [ "$VALUE" -gt 10000 ]
then
        dosomething
else
        dosomethingelse
fi

# 3  
Old 11-13-2014
what will happen if we are using [[ ]] . whats the difference between [ and [[
# 4  
Old 11-13-2014
Why dont you test yourself and ask us AFTER what is still unclear to you ?
These 2 Users Gave Thanks to vbe For This Post:
# 5  
Old 11-13-2014
Quote:
Originally Posted by ramkumar15
what will happen if we are using [[ ]] . whats the difference between [ and [[
[[ ... ]] supports everything [ ... ] does and more, it's an extended syntax. I am supposed to be getting into the habit of using [[ ... ]] all the time as pretty much mandated by standard now, but it's a hard habit to break.
# 6  
Old 11-13-2014
Quote:
Originally Posted by Corona688
[[ ... ]] supports everything [ ... ] does and more, it's an extended syntax. I am supposed to be getting into the habit of using [[ ... ]] all the time as pretty much mandated by standard now, but it's a hard habit to break.
No. The POSIX standards and the Single UNIX specifiations do not yet specify [[ ... ]].

Note that test and its synonym [ are (built-in) utilities, while [[ expression ]] is a part of the shell programming language (l.e., [[ is a keyword not a utility name).

A bug report (#375) was filed in February 2011 that has morphed into a proposal to include a subset of the expressions some shells support with:
Code:
[[ expression ]]

syntax in the next revision of the standards. But even with the comments added last month, we still don't have a proposal that is likely to pass ballot requirements (at least 75% approval) to become part of the standards yet.
This User Gave Thanks to Don Cragun For This Post:
# 7  
Old 11-14-2014
Possibly germane:
test
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep lines for number greater than given number

Hello, I am newbie to bash scripting. Could someone help me with the following. I have log file with output as shown below **************************LOG************************* 11/20/2013 9:11:23.64 Pinging xx.xx.xx.xx with 32 bytes of data: 11/20/2013 9:11:23.64 Reply from xx.xx.xx.xx:... (4 Replies)
Discussion started by: meena_2013
4 Replies

2. Shell Programming and Scripting

Egrep a number greater than in a column

i'm aware awk can do what i'm trying to do here. but i cant use awk in this scenario given the circumstance of this box. but i need to check if a number is a certain column is over a certain value, say for instance, 20. data: | 12 | 19 | 2000 | 9029333 |... (11 Replies)
Discussion started by: SkySmart
11 Replies

3. Shell Programming and Scripting

Egrep a greater than number

data: hello mr smith 400 you all ok? hello mrs. smith 700 you all ok? hello mr. everyone 150 you all ok? hello mr. you all 199 im lad you are ok using egrep, how can i grep out only lines that have a number greater than 250? cat data | egrep ..... can't use awk here. i was... (7 Replies)
Discussion started by: SkySmart
7 Replies

4. UNIX for Dummies Questions & Answers

List of Files which are Greater then a specific date

A newbie question... I need to get a list of the Files and folders which are greater then a specific date. I want write the output to a Text file. What I know ls -lrt gives me list of all the files ordered by date. Also ls > fileName will write the results to a text file. Please help (6 Replies)
Discussion started by: rkaif
6 Replies

5. Shell Programming and Scripting

AWK: Cannot read Number of records greater than 1(NR>1)

Hi all, I have a tab-delimited text file of size 10Mb. I am trying to count the number of lines using, grep -c . sample.txtor wc -l < sample.txt or awk 'END {print NR}' sample.txtAll these commands shows the count as 1, which means they are reading only the first header line of the file.... (3 Replies)
Discussion started by: mehar
3 Replies

6. UNIX for Dummies Questions & Answers

check if a decimal number is greater than zero

Hello, In my code I am checking to see if a variable that contains a decimal number is greater than 0 in the following manner: if do something fi However I am getting the error message (if $i for the current iteration holds 9.6352) command 9.6352 is not found How can I rectify... (5 Replies)
Discussion started by: Gussifinknottle
5 Replies

7. Shell Programming and Scripting

Delete words greater than a specific length

HI All, I have a file with contents like this: apple computer terminal applecomputernetworkrouterterminalrouter network router applecomputernetworkrouterterminalrouter I want to remove all lines with length greater than "18 alphabets". Hence, my output should be: apple computer... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

8. Shell Programming and Scripting

[Solved] Select the columns which have value greater than particular number

i have a file of the form 9488 14392 1 1.8586e-07 5702 7729 1 1.8586e-07 9048 14018 1 1.8586e-07 5992 12556 1 1.8586e-07 9488 14393 1 1.8586e-07 9048 14019 1 1.8586e-07 5992 12557 1 1.8586e-07 9488 14394 ... (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

9. Shell Programming and Scripting

Show result only if number is greater then

Hello all Im trying to write one liner that will show me results only if the result of the expression is greater then 0 For example: I do : find . -name "*.dsp" | xargs grep -c SecurityHandler the result are : ./foo/blah/a.dsp:0 ./foo/blah1/b.dsp:1 ./foo/blah2/c.dsp:2... (1 Reply)
Discussion started by: umen
1 Replies

10. Shell Programming and Scripting

Deleting specific files greater then 90 days

I have a directory that contains a number of history files for a process. Every file starts with the string "EVACK". FOr example EVACK0101.000001 EVACK0102.095940 EVACKmmdd.hhmiss I want to erase in the specific directory ONLY(no sub-directories) all EVACK files older then 90 days. I... (2 Replies)
Discussion started by: beilstwh
2 Replies
Login or Register to Ask a Question