Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 05-06-2004, 03:06 PM   #1
Registered: Jul 2003
Location: NC
Distribution: Fedora,Mepis,Debian
Posts: 84

Rep: Reputation: 15
Need text pattern compare script

I am looking for a text compare program/script that basically compares white spaces. In other words; Are two files formatted the same even if the data in the various fields is different between the two files? I have looked at sed , awk, diff, cmp and several forums to try to locate such a tool but have been unsuccessful so far.

The details are that I have an automated process that generates a EDI transmittal file containing invoice details (price, manufacturer and product numbers, volumes, order number, quantity,etc. This file is sent to customer for payment. Occasionally there is a need to perform some manual manipulations to the file and I want to be able to compare the changed one to an untouched "properly formatted" one to see that the manual changes were performed properly (at least in regard to formatting)?
Thanks in advance.
Old 05-06-2004, 03:17 PM   #2
Registered: Oct 2003
Location: Springfield, MO
Distribution: Ubuntu, IPCop
Posts: 33

Rep: Reputation: 15
Linux-friendly, but not Linux per se

It sounds like you have some programming chops, I'd reccomend looking at Regular Expressions for what you want. As for what kind of script, I'd say Perl myself but I'm biased towards it and not really aware of what might work best. With RegXs you could specify it to look for specific layouts of white space and new lines

I'm pretty sure Bash shell scripts will support regular expressions in addition to several of the Linux utilities...anyone else, yay, nay?
Old 05-06-2004, 03:22 PM   #3
Matt Collier
Registered: Apr 2004
Distribution: Debian
Posts: 80

Rep: Reputation: 15
i'd give a big 'yay' for Perl, but i think you'd have a pretty hard time finding a Perl programmer giving a 'nay', particularly for a text parsing gig
Old 05-06-2004, 03:22 PM   #4
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
I'd probably go with perl too. What are you trying to compare - just blank lines or white space in other lines too? We could probably whip up a quick example if you can post a couple of example files, ie the before and after.
Old 05-10-2004, 01:13 PM   #5
Registered: Oct 2003
Location: Springfield, MO
Distribution: Ubuntu, IPCop
Posts: 33

Rep: Reputation: 15
If someone more knowledgeable than I can reccomend a good module, he could hit CPAN and be on his way....


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to replace string pattern with multi-line text in bash script? brumela Linux - Newbie 6 04-21-2011 06:56 AM
renaming text files based upon a pattern in their content Spacepup Linux - General 1 07-28-2005 01:43 PM
how to compare 2 text files by using php code antony_csf Programming 3 10-14-2004 05:52 AM
Removing Text in a single line starting with one pattern ending on another mgwheeler Programming 13 08-03-2004 04:36 PM
Find string pattern in directory of text files magnum818 Linux - Newbie 2 10-15-2003 08:19 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:16 PM.

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