Search Results

Search: Posts Made By: TierAngst
3,248
Posted By TierAngst
Oh well. And I'm the idiot here, learning to...
Oh well. And I'm the idiot here, learning to program :-P

Thanks for the help everyone!
3,248
Posted By TierAngst
This worked (though I'm sure egrep would've been...
This worked (though I'm sure egrep would've been fine too):
if ! [[ `echo $1 | grep "^[0-9]*$"` ]]

Also, decided to put a counter in each of the improper argument tests so that I could stop the...
3,248
Posted By TierAngst
For the first two: Input: ./math 3 p sd ...
For the first two:
Input:
./math 3 p sd
Output:
Result is 3

With case it gives:
./math: Bad left number "3"
./math: Bad right number "sd"
Result is 3
3,248
Posted By TierAngst
Whoa, I have no idea what that means. Can you...
Whoa, I have no idea what that means. Can you please explain the logic behind this? I'll try it now though.
3,248
Posted By TierAngst
Neither of those cures my problem. It still reads...
Neither of those cures my problem. It still reads non numbers as zero.
3,248
Posted By TierAngst
Comparison treating strings as zero integers
I'm trying to write a bash script to perform basic arithmetic operations but I want to run a comparison on the arguments first to check that they're a number greater than zero.

I want an error to...
Showing results 1 to 6 of 6

 
All times are GMT -4. The time now is 09:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy