Sorry to correct you, but the behavior of "test" (/usr/bin/test) is standardized by POSIX and "-gt" can be expected to work in a certain way on every standard-conformant platform, regardless of the shell
To add: -gt also works in non-Posix shells, like Bourne shell and KSH88, any shell as long as it is Bourne-shell derived (so not csh or tcsh)..
Quote:
This (the aforementioned) is true for constructs like:
and
Shell-dependant is this:
because "[[" is a (shell-builtin) replacement for "[" and "test" and hence depending on the shell it is built into. Some shells (for incstance the ksh88 on AIX) implements "[" as a shell-builtin too, but if this is the case it should conform to the POSIX-standard, whereas the standard says nothing about "[[".
[..]
[ ... ] or test is also a shell builtin utility in every implementation I know of posix compliant shells [[ ... ]] is not a shell builtin utility, but are shell keywords (part of the shell syntax) (They are indeed not part of the POSIX specification, so only supported in certain shells (ksh, zsh, bash)).
Last edited by Scrutinizer; 09-16-2016 at 01:06 AM..
Hello every one! I need a little help. I would like to know if there is someway I can use a "greater than" condition in a shell script.
#!/usr/bin/sh
_curTime=`date +%H%M`
if &&
then
echo "$_curTime"
fi
I know that "<" and ">" is to input and output to a file I just wanted... (2 Replies)
I need to grep out usernames with UID's greater than 200 out of the /etc/passwd file for a server migration. It is the third field however I am not sure to to accomplish this. I tried to search the forums but did not seem to find an answer (might have over looked it). Any help would be... (2 Replies)
Sorry for such a basic question, but I have spent hours trying to work this out! I need an awk command (or similar) that will look at a text file and output to the screen if the 4th column of each line has a value greater than or equal to x.
data.txt
This is the 1 line
This is the 2 line
This... (6 Replies)
I have some ASCII files containing numerous numbers. What I'd like to do is replace all numbers greater than 0 with 1.
Examples of the numbers include: - 000011 and 000042
Thanks (4 Replies)
BASH problem with IS GREATER THAN OR EQUAL TO.
I have tried a dozen variations for this IF statement to work with IS GREATER THAN OR EQUAL TO. My code below WORKS.
array=( $( /usr/bin/sar -q 1 30 |grep Average |awk '{print $2,$3}' ) )
nthreads="${array}"
avproc="${array}"
if && ; then ... (6 Replies)
Hi
I want to find greater than and min value.
dategrep()
{
varlinenum=$1
varSESSTRANS_CL="$(egrep -n "<\/SESSTRANSFORMATIONINST>" tmpsess9580.txt | cut -d":" -f1)"
echo $varSESSTRANS_CL
}
dategrep 8
Output of the above command is:
I want to find out greater than 8 and... (9 Replies)
I have an output from db which looks like :
row1 row2 row3
abc 21.1 13
efg 21.1 45
ghi 21.1 75
when I apply following command ( cat my_output.txt | awk {'print $ 4' }
I have following output :
row3
13
45
75
now I want to figure out if... (4 Replies)
I have a file with multiple fields, example below
File 1:
Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|100
Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|101
Field 1|Field 2|Field 3|Field 4|Field 5|Field 6|Field 7|102
Field 1|Field 2|Field 3|Field 4|Field 5|Field... (4 Replies)
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)