Sponsored Content
Top Forums Shell Programming and Scripting Using IF statements with maths where the input is not an integer Post 302546817 by yazu on Friday 12th of August 2011 08:40:33 AM
Old 08-12-2011
Try string comparison:
Code:
if [ "$input" != "0" ]; then
...


Last edited by yazu; 08-12-2011 at 10:18 AM.. Reason: double posting
This User Gave Thanks to yazu For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem with Maths

Heres a script i wrote as a bit of practise. What it does is insert a line in the middle of a file. The line being $1 and the file being $2 #!/bin/bash rm tempfile touch tempfile count=1 linenum= `wc -l < $2` if then echo $1 >> $2 else even=`expr "$linenum" % 2` if then... (3 Replies)
Discussion started by: Quesa
3 Replies

2. Shell Programming and Scripting

isql input file with multiple sql statements

I've got: isql -U $USERID -S $SERVER -D $DATABASE -i inputfile.sql -o outputfile.txt in inputfile I have: go sql#1 go sql#2 go sql#3 go I also tried without "go" and with";" instead which did not work SQL statements will work if I paste them directly into the script and use EOF ... (0 Replies)
Discussion started by: Cailet
0 Replies

3. Shell Programming and Scripting

Perl - maths equation - need help

if input to the perl program is ' ( p * ((a+b) * (c+d))) + q ' it shuld give the output as ' pac + pad + pbc + pbd + q ' .can anyone suggest a way to do this ? (7 Replies)
Discussion started by: Anuj8584
7 Replies

4. Programming

How i can read a long integer from standar input and a string with as many characters as specified..

how i can read a long integer from standar input and a string with as many characters as specified in the number? i thing that i must use the read command ofcourse.... (6 Replies)
Discussion started by: aintour
6 Replies

5. Shell Programming and Scripting

Maths with variables

Hello, I'm trying to write a while loop for a decimal value in tcsh which I know can't be done. Instead I want my increments to be one order of magnitude too large and then divide it by 10 when I use the variable. However, I don't know how to divide my variable and set it as another. set... (1 Reply)
Discussion started by: DFr0st
1 Replies

6. UNIX for Dummies Questions & Answers

Check if input is an integer or a floating point?

Hiii I actually intent to check the integer or floating point number input by user i.e. 23, 100, 55.25, 12.50 ..etc. However, when someone input strings or alpha character, my program has to show invalid input.!! Is there any Unix shell script syntax can help me to check ? Thanking you (2 Replies)
Discussion started by: krishnampkkm
2 Replies

7. Programming

I don't know how to replace input char with appropriate integer

Hi guys, I asked for help on programming forums and no one didn't helped me so I ask for help here. I am playing with some tasks from my book and I can't figure where did I get wrong. From the first program I get a blank screen, program won't generate 10*10 matrix. And second problem is I... (6 Replies)
Discussion started by: solaris_user
6 Replies

8. Shell Programming and Scripting

Simple maths calculator loop.

Hi, I am trying to make a maths calculator that: 1. Prompts the user for a number. 2. Prompts the user for an operation (add, subtract, divide or multiply) 3. Prompts the user for a number. 4. Prompts the user for another operation (same as above) OR the option to get the result for the... (4 Replies)
Discussion started by: johnthebaptist
4 Replies

9. Shell Programming and Scripting

Maths in shell scripts

Hi, Need help on this. I need to increment a variable by 1 but retain as 2 characters. I am using expr to do additions: NEWSERIAL=`expr $SERIAL + 1` $SERIAL can range from 01-99. After adding "1", I need the result to be 2 characters, eg: 02+1 = 03. By default expr will truncate the... (4 Replies)
Discussion started by: vchee
4 Replies

10. Shell Programming and Scripting

Calculate the constant e to 14+ decimal places using integer maths.

Hi guys... I am loving this integer maths thing. 64 bit systems are certainly easier than 32 bit, but hey, I don't intend to leave out my fav' platform. Using one of the 'Brothers' methods, URL inside the code. #!/bin/sh # # #!/usr/local/bin/dash # e_constant.sh # Brother's formula . #... (2 Replies)
Discussion started by: wisecracker
2 Replies
gdal_merge(1)						      General Commands Manual						     gdal_merge(1)

NAME
gdal_merge - gdal_merge.py mosaics a set of images SYNOPSIS
gdal_merge.py [-o out_filename] [-of out_format] [-co NAME=VALUE]* [-ps pixelsize_x pixelsize_y] [-tap] [-separate] [-v] [-pct] [-ul_lr ulx uly lrx lry] [-n nodata_value] [-init "value [value...]"] [-ot datatype] [-createonly] input_files DESCRIPTION
This utility will automatically mosaic a set of images. All the images must be in the same coordinate system and have a matching number of bands, but they may be overlapping, and at different resolutions. In areas of overlap, the last image will be copied over earlier ones. -o out_filename: The name of the output file, which will be created if it does not already exist (defaults to 'out.tif'). -of format: Output format, defaults to GeoTIFF (GTiff). -co NAME=VALUE: Creation option for output file. Multiple options can be specified. -ot datatype: Force the output image bands to have a specific type. Use type names (ie. Byte, Int16,...) -ps pixelsize_x pixelsize_y: Pixel size to be used for the output file. If not specified the resolution of the first input file will be used. -tap: (GDAL >= 1.8.0) (target aligned pixels) align the coordinates of the extent of the output file to the values of the -tr, such that the aligned extent includes the minimum extent. -ul_lr ulx uly lrx lry: The extents of the output file. If not specified the aggregate extents of all input files will be used. -v: Generate verbose output of mosaicing operations as they are done. -separate: Place each input file into a separate stacked band. -pct: Grab a pseudocolor table from the first input image, and use it for the output. Merging pseudocolored images this way assumes that all input files use the same color table. -n nodata_value: Ignore pixels from files being merged in with this pixel value. -a_nodata output_nodata_value: (GDAL >= 1.9.0) Assign a specified nodata value to output bands. -init 'value(s)': Pre-initialize the output image bands with these values. However, it is not marked as the nodata value in the output file. If only one value is given, the same value is used in all the bands. -createonly: The output file is created (and potentially pre-initialized) but no input image data is copied into it. NOTE: gdal_merge.py is a Python script, and will only work if GDAL was built with Python support. EXAMPLE
Create an image with the pixels in all bands initialized to 255. % gdal_merge.py -init 255 -o out.tif in1.tif in2.tif Create an RGB image that shows blue in pixels with no data. The first two bands will be initialized to 0 and the third band will be initalized to 255. % gdal_merge.py -init "0 0 255" -o out.tif in1.tif in2.tif AUTHORS
Frank Warmerdam warmerdam@pobox.com, Silke Reimer silke@intevation.de GDAL
Tue Sep 18 2012 gdal_merge(1)
All times are GMT -4. The time now is 03:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy