Sponsored Content
Top Forums Shell Programming and Scripting How to calculate the difference between two adjacent columns? Post 302377481 by rdcwayx on Friday 4th of December 2009 07:24:51 AM
Old 12-04-2009
Quote:
Originally Posted by Fredrick
Thank you "rdcwayx", but the output is having only one column, i need the output in the same was as the inputs are. Can you help me in this regard?

HTML Code:
awk 'function abs(val) {return val>0?val:-val } 
for (i=1; i<NF; i++) {if (abs($i - $(i+1))>10) print 1; else print 0}' urfile
Warm regards
Fredrick.
Code:
awk 'function abs(val) {return val>0?val:-val }
{for (i=1; i<NF; i++) {if (abs($i - $(i+1))>10) printf "1 "; else printf "0 "}} {print "\n"}' urfile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to calculate this time difference

Hi, Please help me in calculating the time difference between below mentioned timestamps. a=07/17/2007 02:20:00 AM MST b=07/17/2007 02:07:46 AM MST Thanks (2 Replies)
Discussion started by: Prat007
2 Replies

2. Shell Programming and Scripting

How to calculate the time difference...

Hi All, I've written a script which reads all the systems backup information and saves it in a log file. ssh -l ora${sid} ${primaryhost} "tail -2 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" |head -1 | awk '{print echo "PREVIOUS:-- Start Date&Time: " $3,$4,echo "|| End Date&Time:... (1 Reply)
Discussion started by: suri.tyson
1 Replies

3. Shell Programming and Scripting

How to calculate the time difference.

Hi All, I've written a script which reads all the systems backup information and saves it in a log file. ssh -l ora${sid} ${primaryhost} "tail -1 /oracle/$ORACLE_SID/sapbackup/back$ORACLE_SID.log" | awk '{print $3,$4,$5,$6}' >> ${RESULTFILE} The output comes as below: 2008-09-30 06.00.01... (2 Replies)
Discussion started by: suri.tyson
2 Replies

4. Shell Programming and Scripting

Calculate age of a file | calculate time difference

Hello, I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes... I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes. To do... (10 Replies)
Discussion started by: worm
10 Replies

5. UNIX for Dummies Questions & Answers

help to identify duplicate columns adjacent value

Hi friends, I have a xlsheet like below first column having id ABCfollowed by 7digit numbers and the next column have title against the ids. Titles are unique and duplicateboth, but ids are unique even for duplicate title.Now I need to identify those duplicate title having the highest id for... (9 Replies)
Discussion started by: umapearl
9 Replies

6. Shell Programming and Scripting

How to Calculate the difference between two dates?

I want the difference between two following date using scripts in terms of no.of days. How I can accomplish this. lastdate=Tue Nov 13 10:30:56 2012 currdate=Wed Dec 15 15:58:21 PAKST 2012 Ouput should be like this: Your Password will expire after = 32 Days on Wed Dec 15 15:58:21 PAKST... (1 Reply)
Discussion started by: m_raheelahmed
1 Replies

7. Shell Programming and Scripting

Calculate the difference of two columns and keep the line with specific value

Hi everyone, I am trying to find sty all day. I have two files: File 1: N 82 AAA A 1 0.67 N 83 BBB B 1 0.79 N 84 CCC C 1 0.11 File 2: N 82 AAA A 1 0.63 N 83 BBB B 1 0.03 N 84 CCC C 1 0.08 I want to calculate... (2 Replies)
Discussion started by: Tzole
2 Replies

8. Shell Programming and Scripting

How to calculate difference:?

Experts, file1 : Want to find the difference of $3 field from next line's 3rd field, The difference to be calculated from next lines 3rd field, to current lines lines 3rd field. file1 : Jun24_2013.06242013 3301244928 3133059904 167370640 95% Jun25_1124.06252013 3301244928... (4 Replies)
Discussion started by: rveri
4 Replies

9. Shell Programming and Scripting

Calculate percentage difference between two columns

I have a input text file in this format: ITEM1 10.9 20.1 ITEM2 11.6 12 ITEM3 14 15.7 ITEM5 20 50.6 ITEM6 25 23.6 I want to print those lines which have more than 5% difference between second and third columns. (8 Replies)
Discussion started by: ctrld
8 Replies

10. Shell Programming and Scripting

awk to calculate difference of split and sum the difference

In the awk I am trying to subtract the difference $3-$2 of each matching $4 before the first _ (underscore) and print that value in $13. I think the awk will do that, but added comments. What I am not sure off is how to add a line or lines that will add sum each matching $13 value and put it in... (2 Replies)
Discussion started by: cmccabe
2 Replies
SMMIXER(8)						     Linux Programmer's Manual							SMMIXER(8)

NAME
smmixer - get/set Linux soundcard packet radio modem driver mixer SYNOPSIS
smmixer [-i device] [ params ] DESCRIPTION
smmixer displays and/or sets the input source and input and output levels of a soundcard modem port. OPTIONS
smmixer accepts the following option: -i The device argument specifies the soundcard modem device which should be configured or interrogated. It will usually have the fol- lowing form: sm[0-3]. PARAMETERS
The AD1848 (WSS) mixer accepts the following parameters: ol=val sets the level of the left output to the specified value. Legal values are from -100..0dB. or=val sets the level of the right output to the specified value. Legal values are from -100..0dB. o=val sets the level of both outputs to the specified value. Legal values are from -100..0dB. il=val sets the level of the left input to the specified value. Legal values are from 0..43dB. ir=val sets the level of the right input to the specified value. Legal values are from 0..43dB. i=val sets the level of both inputs to the specified value. Legal values are from 0..43dB. sl=val sets the source of the left input to the specified value. Legal values are line, aux1, mic or dac. sr=val sets the source of the right input to the specified value. Legal values are line, aux1, mic or dac. s=val sets the source of both inputs to the specified value. Legal values are line, aux1, mic or dac. The CT1335 (SB2.x) mixer accepts the following parameter: o=val sets the output level to the specified value. Legal values are from -46..0dB. The CT1345 (SBPro) mixer accepts the following parameters: ol=val sets the level of the left output to the specified value. Legal values are from -46..0dB. or=val sets the level of the right output to the specified value. Legal values are from -46..0dB. o=val sets the level of both outputs to the specified value. Legal values are from -46..0dB. s=val sets the input source to the specified value. Legal values are mic, cd or line. The CT1745 (SB16, SB32 AWE) mixer accepts the following parameters: ol=val sets the level of the left output to the specified value. Legal values are from -62..18dB. or=val sets the level of the right output to the specified value. Legal values are from -62..18dB. o=val sets the level of both outputs to the specified value. Legal values are from -62..18dB. il=val sets the level of the left input to the specified value. Legal values are from -62..18dB. ir=val sets the level of the right input to the specified value. Legal values are from -62..18dB. i=val sets the level of both inputs to the specified value. Legal values are from -62..18dB. s=val enables the specified value as a source. Legal values are line, line.l, line.r, midi, midi.l, midi.r, cd, cd.l, cd.r or mic. CONSIDERATIONS
It is important that the audio levels of your radio match those of the soundcard. To help achieve this, use the smdiag utility. This utility can only be used after the interface is started up, i.e. after ifconfig sm? up. The sound driver and the soundcard modem driver are mutually exclusive, i.e. they cannot both access the same soundcard at the same time. Even worse, the sound driver reserves the soundcard as soon as it gets loaded. The souncard modem driver however reserves the card only when the interface is started, i.e. during ifconfig if up. 9600 baud may not currently work on SoundBlaster cards with DSP revision 4.x, i.e. SB16 and SB32 AWE. This is because they seem to not be fully backwards compatible. SEE ALSO
smdiag (8), sethdlc (8), linux/drivers/net/soundmodem.c AUTHOR
smmixer was written by Thomas Sailer (t.sailer@alumni.ethz.ch). Smmixer 0.1 1 October 1996 SMMIXER(8)
All times are GMT -4. The time now is 09:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy