Sponsored Content
Top Forums Shell Programming and Scripting Help with showing the difference in two lines of input Post 302167152 by Kweekwom on Wednesday 13th of February 2008 03:48:04 PM
Old 02-13-2008
Quote:
Originally Posted by Sathy153
#!/bin/bash

echo "Input numbers"
read input1
echo "Input numbers"
read input2

if [ "$input1" == "$input2" ]
then
echo "Match"
else
echo " The numbers that don't match are: "

awk -v a="$input1" -v b="$input2" 'BEGIN {x=split(a,arra," ");y=split(b,arrb,"
")

if ( x > y)
{ for ( i=1; i<=x; i++)
if ( arra[i] != arrb[i] )
{
if ( arra[i] == arrb[i+1] )
{
print arrb[i]
break
}
else if ( arra[i+1] == arrb[i] )
{
print arra[i]
break
}
else
print arra[i] " <---> " arrb[i]
}
exit }
else if ( x < y )
{ for ( i=1; i<=y; i++)
if ( arra[i] != arrb[i] )
{
if ( arra[i] == arrb[i+1] )
{
print arrb[i]
break
}
else if ( arra[i+1] == arrb[i] )
{
print arra[i]
break
}
else
print arra[i] " <---> " arrb[i]
}
exit }
else ( x = y )
{ for (i=1; i<=x; i++)
if ( arra[i] != arrb[i])
{
if ( arra[i] == arrb[i+1] )
{
print arrb[i]
break
}
else if ( arra[i+1] == arrb[i] )
{
print arra[i]
break
}
else
print arra[i] " <---> " arrb[i]
}
exit }
}'

fi
Thanks for the help, but this doesn't work quite right either.

If for example, I enter the following:

Input1: 1 2 6 4 70
Input2: 1 6 2 4 80 90 670

I get the following response:

Nodes that do not match are:

6

Even though there are many more mismatches than just the 6.

Anyway to fix this? Thanks again!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

word count showing wrong number of lines

Hi , I am using SUN OS Version 5.6. I have a file that contains records of length 270. when I do 'set nu' in vi editor, I get the count as 86. whereas when I do "wc -l" on the command prompt, it shows the count as only 85. this is very strange. why would the 'wc' show 1 record less. The job... (3 Replies)
Discussion started by: tselvanin
3 Replies

2. UNIX for Dummies Questions & Answers

counting lines and showing the output

First time poster - I have a huge file and i want to sort and compress it to something more readable Ex: FUTNCA01-SL1 DMT8a4 5 3 FUTNCA01-SL1 DMT8a4 5 9 FUTNCA01-SL1 DMT8a4 5 21 FUTNCA01-SL1 DMT8a4 5 22 FUTNCA01-SL1 DMT8a4 5 23 FUTNCA01-SL1 DMT8a4 5 24 FUTNCA01-SL1 DMT8a4 6 2... (13 Replies)
Discussion started by: jjoves
13 Replies

3. UNIX for Dummies Questions & Answers

awk help in calulating difference for last two lines

Hi all, I have a requirement for a script to find out the increase in memory. We have a log native_stderr.log where this will log. bash-2.05$ tail -40 native_stderr.log | grep ': freed' <GC(4140): freed 168190456 bytes, 66% free (180990488/271776256), in 253 ms> <GC(4141): freed... (4 Replies)
Discussion started by: senthilkumar_ak
4 Replies

4. Shell Programming and Scripting

difference between 1 st fields from consicutive lines

13608:End of Tests. 13811:End of Tests. 14014:End of Tests. 14217:End of Tests. 14420:End of Tests. 14623:End of Tests. 14826:End of Tests. 15029:End of Tests. 15232:End of Tests. 15435:End of Tests. 15638:End of Tests. i have file like above. i want difference betwwn first field of... (2 Replies)
Discussion started by: pankajd
2 Replies

5. Shell Programming and Scripting

Showing the first 4 lines of a file?

Is there a way to show the first 4 lines of a file without using head -4? In sed would it be sed '1,4d' ? What if I just wanted to display the 2nd line ONLY? How could this be done with AWK?...correctly with SED? (6 Replies)
Discussion started by: puttster
6 Replies

6. Shell Programming and Scripting

Help with script or command to differentiate difference between two input file?

I got two file write now. Input file 1: >data_1 DSFDFDSGFDSGSGEGTRTRERPOYIORPGKKGDSPKFSDKFPSDKFSPFS >data_34 WEEREREWREWOIQOPIEPDSKLFNDSFNSKNCASKJHDAFHAOUDFEOWWIOUFEWIUEWIRUEWIRUEWIORUEWOREWR >data_21 ASDASDQWEQWRQERFWPOTGIUWEIPOFIOFDSNFKSJDNFSKDHFKDSJHFKDSJHF >data_4... (14 Replies)
Discussion started by: perl_beginner
14 Replies

7. Shell Programming and Scripting

Perl : code on ping showing difference result

Hi all, I am using the below code to ping a code and print whehter the connection is successful or not. use Net::Ping; $p = Net::Ping->new(); my $host = "x.x.x.x"; # print "$host is alive.\n" if $p->ping($host); if ($p->ping($host,3)) { print... (0 Replies)
Discussion started by: scriptscript
0 Replies

8. Shell Programming and Scripting

What is difference between this two lines in script?

Hi Guys, What is difference between this two lines in script logger -p daemon.info -t postback Starting /opt/local/bin/backup-report and /opt/local/bin/backup-report is the backu script running twice here? Thanks, (2 Replies)
Discussion started by: manalisharmabe
2 Replies

9. Shell Programming and Scripting

Removing multiple lines from input file, if multiple lines match a pattern.

GM, I have an issue at work, which requires a simple solution. But, after multiple attempts, I have not been able to hit on the code needed. I am assuming that sed, awk or even perl could do what I need. I have an application that adds extra blank page feeds, for multiple reports, when... (7 Replies)
Discussion started by: jxfish2
7 Replies

10. Shell Programming and Scripting

Calculate time difference between two lines

i grepped the time stamp in a file as given below now i need to calculate time difference file data: 18:29:10 22:15:50 (5 Replies)
Discussion started by: vivekn
5 Replies
SoTriggerAny(3) 						       Coin							   SoTriggerAny(3)

NAME
SoTriggerAny - The SoTriggerAny class is a fan-in engine for triggers. When any one of the input triggers are 'pulsed', any field connected as a slave to the engine output will be notified. SYNOPSIS
#include <Inventor/engines/SoTriggerAny.h> Inherits SoEngine. Public Member Functions virtual SoType getTypeId (void) const virtual const SoFieldData * getFieldData (void) const virtual const SoEngineOutputData * getOutputData (void) const SoTriggerAny (void) Static Public Member Functions static SoType getClassTypeId (void) static void * createInstance (void) static void initClass (void) Public Attributes SoSFTrigger input0 SoSFTrigger input1 SoSFTrigger input2 SoSFTrigger input3 SoSFTrigger input4 SoSFTrigger input5 SoSFTrigger input6 SoSFTrigger input7 SoSFTrigger input8 SoSFTrigger input9 SoEngineOutput output Protected Member Functions virtual ~SoTriggerAny (void) Static Protected Member Functions static const SoFieldData ** getInputDataPtr (void) static const SoEngineOutputData ** getOutputDataPtr (void) Detailed Description The SoTriggerAny class is a fan-in engine for triggers. When any one of the input triggers are 'pulsed', any field connected as a slave to the engine output will be notified. Constructor &; Destructor Documentation SoTriggerAny::SoTriggerAny (void) Default constructor. SoTriggerAny::~SoTriggerAny (void) [protected], [virtual] Destructor is protected because explicit destruction of engines is not allowed. Member Function Documentation SoType SoTriggerAny::getClassTypeId (void) [static] This static method returns the SoType object associated with objects of this class. Reimplemented from SoEngine. SoType SoTriggerAny::getTypeId (void) const [virtual] Returns the type identification of an object derived from a class inheriting SoBase. This is used for run-time type checking and 'downward' casting. Usage example: void foo(SoNode * node) { if (node->getTypeId() == SoFile::getClassTypeId()) { SoFile * filenode = (SoFile *)node; // safe downward cast, knows the type } } For application programmers wanting to extend the library with new nodes, engines, nodekits, draggers or others: this method needs to be overridden in all subclasses. This is typically done as part of setting up the full type system for extension classes, which is usually accomplished by using the pre-defined macros available through for instance Inventor/nodes/SoSubNode.h (SO_NODE_INIT_CLASS and SO_NODE_CONSTRUCTOR for node classes), Inventor/engines/SoSubEngine.h (for engine classes) and so on. For more information on writing Coin extensions, see the class documentation of the toplevel superclasses for the various class groups. Implements SoBase. const SoFieldData ** SoTriggerAny::getInputDataPtr (void) [static], [protected] Returns the SoFieldData class which holds information about inputs in this engine. Reimplemented from SoEngine. const SoEngineOutputData ** SoTriggerAny::getOutputDataPtr (void) [static], [protected] Returns the SoEngineOutputData class which holds information about the outputs in this engine. Reimplemented from SoEngine. const SoFieldData * SoTriggerAny::getFieldData (void) const [virtual] Returns a pointer to the class-wide field data storage object for this instance. If no fields are present, returns NULL. Reimplemented from SoFieldContainer. const SoEngineOutputData * SoTriggerAny::getOutputData (void) const [virtual] This API member is considered internal to the library, as it is not likely to be of interest to the application programmer. Implements SoEngine. void SoTriggerAny::initClass (void) [static] Sets up initialization for data common to all instances of this class, like submitting necessary information to the Coin type system. Reimplemented from SoEngine. Member Data Documentation SoSFTrigger SoTriggerAny::input0 Input trigger. SoSFTrigger SoTriggerAny::input1 Input trigger. SoSFTrigger SoTriggerAny::input2 Input trigger. SoSFTrigger SoTriggerAny::input3 Input trigger. SoSFTrigger SoTriggerAny::input4 Input trigger. SoSFTrigger SoTriggerAny::input5 Input trigger. SoSFTrigger SoTriggerAny::input6 Input trigger. SoSFTrigger SoTriggerAny::input7 Input trigger. SoSFTrigger SoTriggerAny::input8 Input trigger. SoSFTrigger SoTriggerAny::input9 Input trigger. SoEngineOutput SoTriggerAny::output (SoSFTrigger) Connect to the output with the field(s) you want notified upon any input trigger 'pulses'. Author Generated automatically by Doxygen for Coin from the source code. Version 3.1.3 Wed May 23 2012 SoTriggerAny(3)
All times are GMT -4. The time now is 10:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy