File Comparison using Shell Programming

Hi All,
I want to compare two text files using shell programming. The two text files are actually Business Objects output extracted in a text format. The two output files are not in a tabular format and are no way similar in looking. I want to take one file e.g. file1 as an input file and compare each line of file1 with the other file e.g. file2. During comparison I want to extract the differences found in another file and if possible the similar data as well.
Below is how the files will look like
File 1:
BILL1000000 1111251 122222
RMG1A2 023425100000000010001 11135 102650111100
UHL1 6999999 454540001 Weekly 000
0544424556895PS DATA 01MPS100000/03 MR A A PERTH UTL1234567893106923455053106900000010000005
File 2:
AUTO
APPLICATION=STARTPOINT
START
PROCESSING DATE=01012011
1598301270320099TEST C E 00000031615 123456
7854301276140499TES P 00000062943 234567
UHL1 6999999 454540001 Weekly 000
5569931233333499/123456789 00000013396 345678
4471931233333499ER K J 00000031835123456789012456789
33652931233333499E J L 00000034729123456789012567890
45783123333349921/123456789 00000039080 678901
1452931233333499T R 00000040678123456789012789012
59689312333334994/987654321 00000048614 890123
4112931233333499/987654321 00000060631 901234
1236931217836899 K S 00000043704 012345
END
As you can see above the file are not at all matching except for one record UHL1, but its just an example. As an output I would like to have a third file containing all these records, highlighting the differences, and a fourth file where in only the matched records should get populated.
Please post any useful scripts related to the above scenario.
Many Thanks.

Nik,
Thanks for that script. Its solving my purpose upto an extent.
Going another level to that example, in cases where in the first column of file 1 is to be compared with second or third column in file 2, what all the changes should be made to your script. For example,
File 1:
1       a       APPLICATION=WWAGES      8       9
2       b       1200301270320099TEST  C E         00000031615            123456
3       c       1200301276140499TES  P            00000062943            234567
4       d       APPLICATION=WWAGES      6       7
5       e       1200301270320099TEST  C E         00000031615            123456
6       f       1200301276140499TES  P            00000062943            234567
7       g       APPLICATION=WWAGES      4       5
8       h       1200301270320099TEST  C E         00000031615            123456
9       i       1200301276140499TES  P            00000062943            234567
10      j       APPLICATION=WWAGES      2       3
11      k       1200301270320099TEST  C E         00000031615            123456
12      l       1200301276140499TES  P            00000062943            234567
File 2:
a       1       APPLICATION=WWAGES      8       9
b       2       1200301270320099TEST  C E         00000031615            123456
g       7       APPLICATION=WWAGES      4       5
h       8       11200301270320099TEST  C E         00000031615            12223456
k       12      1200301276140499TES  P            00000062943            234567Now, in the above example First and Second Columns of File 1 are to be compared against Second and First Columns of File 2 respectively. Please see that in file 2, 12 and K are not matching with file1's record 11 and K, so they should not be picked.
Based on the matched columns, will continue comparing rest of the fields for the records.
Please guide me the changes to be done in your script for catering to the above scenario.
Thanks.

Similar Messages

  • Comparing two text files in a UNIX using shell programming

    Hi All,
    Sorry for posting a UNIX shell query on Database forums.
    I want to compare two text files using shell programming. The two text files are actually Business Objects output extracted in a text format. The two output files are not in a tabular format and are no way similar in looking. I want to take one file e.g. file1 as an input file and compare each line of file1 with the other file e.g. file2. During comparison I want to extract the differences found in another file and if possible the similar data as well.
    Below is how the files will look like
    File 1:
    BILL1000000 1111251 122222
    RMG1A2 023425100000000010001 11135 102650111100
    UHL1 *6999999* *454540001* Weekly *000*
    0544424556895PS DATA 01MPS100000/03 MR A A PERTH UTL1234567893106923455053106900000010000005
    File 2:
    AUTO
    APPLICATION=STARTPOINT
    START
    PROCESSING DATE=01012011
    1598301270320099TEST C E 00000031615 123456
    7854301276140499TES P 00000062943 234567
    UHL1 *6999999* *454540001* Weekly *000*
    5569931233333499/123456789 00000013396 345678
    4471931233333499ER K J 00000031835123456789012456789
    33652931233333499E J L 00000034729123456789012567890
    45783123333349921/123456789 00000039080 678901
    1452931233333499T R 00000040678123456789012789012
    59689312333334994/987654321 00000048614 890123
    4112931233333499/987654321 00000060631 901234
    1236931217836899 K S 00000043704 012345
    END
    As you can see above the file are not at all matching except for one record UHL1, but its just an example. As an output I would like to have a third file containing all these records, highlighting the differences, and a fourth file where in only the matched records should get populated.
    Please post any useful scripts related to the above scenario.
    Many Thanks.
    Edited by: 848265 on 06-Apr-2011 04:13

    Hi;
    For your issue i suggest close your thread here as changing thread status to answere and move it to Forum Home » Linux which you can get more quick response
    Regard
    Helios

  • Open *.PDF file by using ABAP program

    Hi,
    Can anyone please tell me about  " how to  open a PDF file by using an ABAP program".
    Regards,
    Prasanth

    Welcome to SDN.
    Refer this class - CL_GUI_PDF_VIEWER
    You may refer this thread also -
    Re: Open Jpg, Excel, word, pdf files from SAP screen.
    Regards,
    Amit

  • How to use shell program parameters in java program??

    Hai all,
    I am writing a java program which must read strings from a file and must assign to variables.these strings are nothing but the output of ls -l command in shell. i need to have all those 9 fields in a file as variables.
    I cant find any method that will read only string.I came accross read line but that is not what i need.So, i thought of writing a shell script and by using awk, storing those 9 fields in 9 variables.. but how to use that variables in java programming???
    the shell script is executed by exec() but i need that variables also.
    Help me please:(
    thanks in advance

    i now changed the code... and closed the output file and then i read.Later i splited with the line i read.. but the same happened...
    this is the code:
    while ((l = inputStream.readLine()) != null)
                        op=new FileOutputStream("op.txt");//output of exec goes to this file
                        String[] cmd= {"/bin/sh","-c","ls -l "+l};
                        rt = Runtime.getRuntime();
                        proc = rt.exec(cmd);
                        // any error message?
                          StreamGobbler errorGobbler = new
                          StreamGobbler(proc.getErrorStream(), "ERR");
                        // any output?
                          StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream(), "",op);
                        errorGobbler.start();
                               outputGobbler.start();
                        op.close();//the file is closed now
                        ip = new BufferedReader(new FileReader("op.txt"));     //now i opened to read
                        p=ip.readLine();
                        a=p.split("\\s");
                        ip.close();
                   }where i went wrong?

  • No MP4 is file created using recording program IPV 5.2

    I've got a stream playing from a DVD player and everything is working great. I've been trying to record the stream to an archive server so I can play it back later but it doesn't seem to be working.
    I define a recording for the program, give it a start time and duration, tell it to record audio and video, give it a file name and select the archive server from the drop down. The recording starts but no media file ever shows up.
    Is there something I'm missing or better yet some sort of step by step guide to help me through
    this ?

    export the file to .mov format and try if it works out.

  • Delete backup files using shell script

    Hi Gurus,
    I have to delete previous month backupfiles like sample.ttp-04-24-06 file from directory called 0424. Like that I need to delete the whole month files by using shell script.
    Please I will run this script once in a month. So it will delete all previous month's backup files which are available in the date directory of that month(0401,0402,0403 etc).
    Please help me out to solve this issue.
    Thanks in advance.

    Hi Fish,
    Its working fine. Thanks a lot for your excellent idea to solve my issue.
    Thanks again.
    bye,
    Peter.

  • To Pick the oldest file using shell script

    Hi All,
    I want to pick the oldest file among the below files in the shell program. I don't know the file name but i know the file extension.
    -rw-r--r-- 1 oracle    dba   0 Jul 10 13:39 1.sh
    -rw-r--r-- 1 oracle   dba    0 Jul 10 13:39 2.sh
    -rw-r--r-- 1 oracle   dba    0 Jul 10 13:39 3.sh
    -rwxr--r-- 1 oracle   dba   7123 Apr  7  2011 xxampp.sh
    -rw-r--r-- 1 oracle  dba    1 Jul 10 12:57 xxaampps.sh
    Here i want to create a shell program  to pick the xxampp.sh which is created earlier.
    Please help me to achieve this task.
    Thanks in advance.
    Regards,
    Nikunj

    oldest=`ls -t *.sh | tail -1`
    echo $oldest

  • Changing physical path in FILE TCODE using ABAP CODE

    Hi all ,
    I want to change physical path linked to logical path in TCODE FILE dynamically using ABAP program. Is it possible.
    If yes then how?
    Thanks for your help.
    Regards,
    Uday.

    s

  • How to generate "CertificateSigningRequest" by using shell command

    Hi,
    I want to create "CertificateSigningRequest" file by using shell command
    We can create this csr file by using keychain.
    Keychain Access/Certificate Assistant/Request a certification from a Certificate Authroity
    I really need your help.
    Thanks
    Meng

    Hi,
    Thanks for your message.
    Yes, it is self-signed Certificate Authrity.
    If it is very easy and free, please let me know.
    Thanks
    Meng

  • How to Email Concurrent Program Output to Email using Shell Script

    Hi All,
    Have a Nice Day,
    I have a tricky requirement and i was not able to achieve, let me explain my requirement
    I have created a PLSQL Concurrent Program named "Approval Update". This will do update and it display the number of rows updated.
    Now i need to take this concurrent program output and it needs to be send it to the person who submits this program as an email using shell scripts.
    I have referred meta link note as well as some OTN posts but I was not able to achieve this.
    Please help me to complete this As soon as possible, Thanks in advance for your help.
    Let me know if you need more clarifications.
    Regards,
    CSK

    I don't have much idea in shell scripts all i want is, in my shell script i need to get the parent concurrent program output and that needs to be emailed to the intended person.
    Please help to to get the shell script commands for this.I do not have any shell script to share, sorry! If you want the query to get the parent request_id so you can get the log/out file name/location from then please refer to:
    REQUESTS.sql Script for Parent/Child Request IDs and Trace File IDs [ID 280295.1]
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONC_REQ_SUMMARY_V&c_owner=APPS&c_type=VIEW
    http://etrm.oracle.com/pls/et1211d9/etrm_pnav.show_object?c_name=FND_CONCURRENT_REQUESTS&c_owner=APPLSYS&c_type=TABLE -- LOGFILE_NAME & OUTFILE_NAME
    Thanks,
    Hussein

  • Printing PDF file Using Shell Command Line

    Hello I am writing  a program from MicroSoft Excel's Macro that will print PDF files. I have managed to get the program to work but I cannot prevent the file not being opened. Basically the PDF file would get printed but the file would automatically opened up.
    I am using shell command line to write this. And this is my code:
    FileName = "C:\EGB Gaming Lab\Training Manual\Testing Documents\Testing Checklists\Bill Validator*"
    myShell.Run ("Acrobat.exe /t" & FileName)
    I have tried using /h but it still opens the file.
    I am referring to this support case:
    http://support.adobe.com/devsup/devsup.nsf/docs/52080.htm
    Thank you

    You may be able to adopt this script:
    on open dropped_items
       -- Write a message into the event log.
       log "  --- Starting on " & ((current date) as string) & " --- "
       -- set see to alias "Macintosh-HD:Users:mac:Desktop:app.html"
       -- set dropped_items to {see}
       set the_app to "Safari"
       repeat with dropped_item_ref in dropped_items
          --set UrlBase to "xzzx FILE://" & POSIX path of dropped_item_ref
          --display dialog UrlBase
          -- Activate
          activate application the_app
          -- Open the URL 
          tell application the_app
             open dropped_item_ref
             -- print dropped_item_ref
             tell application "System Events"
                tell process the_app
                   delay 3
                   -- click menu item "Print..." of menu "File" of menu bar 1
                   keystroke "p" using command down
                   delay 1
                   keystroke return
                   delay 10
                   keystroke "w" using command down
                end tell
             end tell
             --quit
          end tell
       end repeat
    end open

  • File comparison program

    Can anyone recommend a good file comparison program?
    Thanks
    Vic

    Thanks! I'm now playing with Beyond Compare
    A.Translator wrote:
    > Joe Makowiec schreef op 14/11/2008 :
    >>> Can anyone recommend a good file comparison
    program?
    >
    >> Windows has its own built-in 'fc' utility. If you
    don't like that, get a
    >> copy of the GNU utilities ports for Windows[1] and
    use 'diff'
    >
    >>
    http://gnuwin32.sourceforge.net/
    >>
    http://unxutils.sourceforge.net/
    >
    > Or WinMerge (free) from
    http://winmerge.org/
    > or Beyond Compare from
    http://www.scootersoftware.com/
    >

  • Moving ipod files onto a mac WITHOUT using a program

    My computer recently crashed and I have a good 30 songs that are new from the itunes store since the last time I backed up my music files. I have a mac formatted ipod and want to be able to put the music on it back onto the computer, but want to do so without installing or using any programs (as sketchy programs is the reason my computer crashed).
    Does anyone know how to do this? I did it previously when transferring from a PC to a mac, but have since forgotten, but remember there being numerous help topics and explanations on how to go about this before the whole "use a program" fad started. I know it involves opening 'preferences' on the itunes menu so the ipod doesn't automatically update, but what happens next?
    Any help would be extremely appreciated.
    Powerbook G4   Mac OS X (10.4.3)   mac-formatted ipod video

    This link describes how to do it with and without third party software: "Two-way Street: Moving Music Off the iPod" http://playlistmag.com/help/2005/01/2waystreet/

  • How do I find out what program / file is using 100 GB of space on my Hard drive?  Once I find the problem  how do I delete the specific files to increase GB of space?

    How do I find out what program / file is using 100 GB of space on my Hard drive?  Once I find the problem  how do I delete the specific files to increase GB of space?

    Use OmniDiskSweeper
    Once you find file, it can be deleted from within OmniDiskSweeper
    Allan

  • Hi. I recently got a new computer and transferred all my files across using TimeMachine. Whenever I try to sign into any CC program (including CC) the program instantly shuts down and an Apple error message comes up. I have uninstalled and reinstalled CC

    Hi. I recently got a new computer and transferred all my files across using TimeMachine. Whenever I try to sign into any CC program (including CC) the program instantly shuts down and an Apple error message comes up. I have uninstalled and reinstalled CC twice with no avail and deleted every Adobe product on my computer and nothing is working.

    I have seen similar discussions before... transferring does not work, you must install
    Discussions of RE-installing
    -http://forums.adobe.com/thread/1408331?tstart=0
    -http://forums.adobe.com/thread/1398961?tstart=0
    -and http://helpx.adobe.com/creative-cloud/help/install-apps.html
    -using the cleaner after uninstalling and before reinstalling will usually help
    -http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html

Maybe you are looking for