Sponsored Content
Top Forums Shell Programming and Scripting Compare and calculate two variables Post 302876964 by faka on Wednesday 27th of November 2013 11:34:43 AM
Old 11-27-2013
Compare and calculate two variables

Hi, I have two variables with some values with 5 decimal digits and separated with space, the values of the variables are different, I want to make operations with this two variables.
The way was I find to do it itīs with files and
Code:
paste file1 file2 | awk '{print $1 - $2}'

I want to make it with the variables without files.
There is a way to do it?

Code:
Variable1=89.90000 21.65000 28.10000 29.20000 1.80000 2.80000 8.30000 9.80000 1.59770 1.65250 0.91650 0.90270 102.22000 100.80000 1.34410 1.36110 11.91670 7.46430 2.58430 2.13270 4515.47000 4322.26000 2.73080 2.73080 16072.54000 1220.55000 1220.55000
Variable2=95.90000 61.65000 28.10000 29.20000 1.80000 2.80000 8.30000 9.80000 1.59770 5.65250 0.91650 0.90270 102.22000 100.80000 1.34410 1.34110 11.91470 7.46430 2.58430 2.13270 4515.47000 4322.26000 2.73080 2.73080 16072.54000 1220.55000 1220.55000


Last edited by radoulov; 11-27-2013 at 12:43 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do I compare mixed variables?

Searched all over can't figure out how to compare variables of alpha and numeric characters. Example a script that ask user to enter a password and then ask to repeat the password. (6 Replies)
Discussion started by: monx
6 Replies

2. Shell Programming and Scripting

Compare two variables

Hi guys, How do I compare two variables using diff? The way I'm thinking: #!/bin/sh a=cat asdf.x | wc -l b=cat asdf.y |cut -d',' -f5 |grep -v '^$' |wc -l diff $a $b How to rewrite the above sciprt using only one line in command prompt? (2 Replies)
Discussion started by: onthetopo
2 Replies

3. Shell Programming and Scripting

Compare String Variables for Greater or Less Than?

Is there any way to compare two strings for a greater or less than condition? For example, StringA is "apple" and StringB is "bonnet" and StringC is "captain". Can I only test for equal/not-equal, or is there a way to find out whether StringA is less than StringB, and StringC is greater than... (6 Replies)
Discussion started by: OPTIMUS_prime
6 Replies

4. Shell Programming and Scripting

Awk - Compare fields and increment variables

Hi, My first post to this group... I have a need to to parse a source file which is a capture from a network analyser. I have two fields that need to be checked: - Field 7 represents the packet length (an integer), and Field 4 represents a network address (e.g. 192.168.25.3) - The... (10 Replies)
Discussion started by: mv652
10 Replies

5. Shell Programming and Scripting

HELP: compare floating point variables??

Hi All, I got this script that pulls the Amps value from our RPC's , I basiclly want to compare the valued with a "limit" value -- if the numbers match or are greater than the definded value ...do something. My problem is I cant seem to figure out how to compare floating points... here is... (1 Reply)
Discussion started by: zeekblack
1 Replies

6. Shell Programming and Scripting

using awk compare two variables in bash

ok this is probably going to turn out to be something really stupid but i've tried to use the following command in a script but the output is just a blank screen and i have to use Ctrl c to exit it. awk 'BEGIN {printf "%.2f\n", '${bashArray}'>='$Variable' {print '${bashArray}'}}' the command... (2 Replies)
Discussion started by: zagreus360
2 Replies

7. Shell Programming and Scripting

How to compare floating variables , integer value expected?

I am running some commands and I am trying to get an output into a variable. I am having problem when I try to put that value in while loop, it says integer value expected. What's the best way to accomplish this remaining=$(symclone -sid XXX -f Clone_test query | grep MB | awk '{print... (1 Reply)
Discussion started by: rajsan
1 Replies

8. Shell Programming and Scripting

read line by line and calculate the co-presence of variables

Hey guyz, I have a table which shows the presence or absence of my variables (A,B,C,...) in my observations (1,2,3,...) * A B C ... 1 1 0 1 2 1 1 0 3 1 0 0 ... I want to calculate the co-presence of my variables. to have a table shows the pairwise presence of the variables (have... (1 Reply)
Discussion started by: @man
1 Replies

9. Shell Programming and Scripting

Compare two variables and print the difference

Hi PRIM_SEQ=`some sql code` and output of PRIM_SEQ is like below 120 130 STB_SEQ=`some sql code` and output of STB_SEQ is like below 115 110 i need to compare this two variables output ( decimal numbers) 1) What I want to do is to compare every number in the PRIM_SEQ with... (8 Replies)
Discussion started by: amar1208
8 Replies

10. UNIX for Beginners Questions & Answers

Compare two variables and print the difference

compare two variables and print the difference i have two variables X1=rac1,rac2 Y1=rac2,rac3 output=rac1,rac3 Use code tags to wrap code fragments or data samples. (1 Reply)
Discussion started by: jhonnyrip
1 Replies
arcmsr(7D)							      Devices								arcmsr(7D)

NAME
arcmsr - SAS and SATA HBA driver for Areca Hardware Raid devices DESCRIPTION
The arcmsr host bus adapter driver is a SCSA-compliant nexus driver that supports Areca Technology SAS and SATA RAID devices. Supported SATA RAID cards: ARC-1110 pci17d3,1110 ARC-1120 pci17d3,1120 ARC-1130 pci17d3,1130 ARC-1160 pci17d3,1160 ARC-1170 pci17d3,1170 ARC-1201 pci17d3,1201 ARC-1210 pci17d3,1210 ARC-1220 pci17d3,1220 ARC-1230 pci17d3,1230 ARC-1260 pci17d3,1260 ARC-1270 pci17d3,1270 ARC-1280 pci17d3,1280 Supported SAS RAID cards: ARC-1380 pci17d3,1380 ARC-1381 pci17d3,1381 ARC-1680 pci17d3,1680 ARC-1681 pci17d3,1681 CONFIGURATION
There are no user configurable parameters available. Please configure your hardware through the host system BIOS. FILES
/kernel/drv/arcmsr 32-bit ELF kernel module. /kernel/drv/amd64/arcmsr 64-bit kernel module (x64 only). /kernel/drv/arcmsr.conf Driver configuration file (contains no user-configurable options). ATTRIBUTES
See attributes(5) for a description of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |x86, x64 only | +-----------------------------+-----------------------------+ |Availability |SUNWarcmsr | +-----------------------------+-----------------------------+ SEE ALSO
prtconf(1M), attributes(5), scsi_hba_attach_setup(9F), scsi_sync_pkt(9F), scsi_transport(9F), scsi_inquiry(9S), scsi_device(9S), scsi_pkt(9S) Small Computer System Interface-2 (SCSI-2) http://www.areca.com.tw/products/main.htm http://developer.intel.com/design/iio/index.htm --(Intel Corp IO processors provide the underlying RAID engine for the supported devices). SunOS 5.11 28 Feb 2008 arcmsr(7D)
All times are GMT -4. The time now is 07:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy