LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-06-2011, 04:29 AM   #1
Finejason
LQ Newbie
 
Registered: Oct 2005
Location: South Africa
Distribution: Fedora Core 4
Posts: 3

Rep: Reputation: 0
diff the output of one bash script against another


Hi guys

I would like to compare the (screen) output of one bash script with the (screen) output of another bash script to ensure the output is exactly the same.

The reason for this is that I am receiving a consolidated data feed from an IP address and have moved some of the data feed to a 'new' source IP address. I will turn off the feed from the original once satisfied that the new is receiving the same data. The format of the output from the scripts are exactly the same.

Tried so far

./IDCGRE.sh | grep FX.CK | diff < ./IDCGRE2.sh
./IDCGRE.sh | grep FX.CK | ./IDCGRE2.sh | diff
diff "./IDCGRE.sh | grep FX.CK" ./IDCGRE2.sh

I'll tail 5 seconds worth of data every 60 seconds into a file for each bash script and then run diff on the output files. Execution start time will cause some differences at the begining/end of file.

Using this helpful method

http://www.bashcookbook.com/bashinfo...ripts/timeout3


Would just like to know if there is a way to compare output rather than files with diff or any other?
 
Old 07-06-2011, 05:16 AM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,508

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Use process substitution:
Code:
diff <(./IDCGRE.sh | grep FX.CK) <(./IDCGRE2.sh | grep FX.CK)
the two outputs will be compared after both the scripts have terminated.
 
1 members found this post helpful.
Old 07-07-2011, 02:21 AM   #3
Finejason
LQ Newbie
 
Registered: Oct 2005
Location: South Africa
Distribution: Fedora Core 4
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you colucix!

Thanks mate that was very helpful. I have managed to complete the task and now have a way to test feeds in future. My final command looks a little different because I need to remove sequence numbers and a few milliseconds from a portion of each output but your answer was absolutely spot on!

Here's what I ended up with - messy but it seems to work. snapFeed.sh is the timeout script (unchanged!) mentioned in original post.

diff <(./snapFeed.sh -t 25 /home/gtr/vtmfDump/./IDCGRE.sh | ./snapFeed.sh -t 25 grep FX.CK | ./snapFeed.sh -t 25 awk '{print $2 substr($3,0,42) substr($3,45);for (i=4;i<=NF; i++) printf $i;}'
) <(./snapFeed.sh -t 25 /home/gtr/vtmfDump/./IDCGRE2.sh | ./snapFeed.sh -t 25 grep FX.CK | ./snapFeed.sh -t 25 awk '{print $2 substr($3,0,42) substr($3,45);for (i=4;i<=NF; i++) printf $i;}'
)


Once again, thanks for the help.
 
Old 07-07-2011, 02:41 AM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,508

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
You're welcome!
 
  


Reply

Tags
compare, diff, grep, tail, timeout


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH: Help with formatting Output from a script SilversleevesX Programming 4 08-23-2010 06:59 PM
[bash] auto fix file from diff output RaptorX Programming 3 08-02-2009 05:17 PM
[SOLVED] Bash script - how to use output from diff and find in context with cpio Mogget Programming 4 01-23-2009 10:38 AM
Test output from bash script estratos Programming 6 11-16-2006 09:01 PM
Bash Script, calculate output. eldaria Programming 13 07-20-2006 09:26 PM


All times are GMT -5. The time now is 06:44 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration