Results 1 to 6 of 6
  1. #1
    Join Date
    May 2003
    Posts
    369

    Unanswered: using an array and loop to take diffs

    I am trying to clean up an older shell script that uses the following format with an array and loop:

    current:

    diff ${DIR}_a.dat ${DIR}_b.dat>${DIR}_diff.dat

    proposed

    loop thru array of 3 elements:

    arr[0]=${DIR}_a.dat
    arr[1]=${DIR}_b.dat
    arr[2]=${DIR}_c.dat
    #
    # take diffs
    #
    echo `diff arr[0] arr[1]`>diff1.dat
    echo `diff arr[1] arr[2]`>diff2.dat

    However I keep getting errors when I perform the diffs on the array. Can anyone help me out? Thanks

  2. #2
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    what kind of errors?
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

  3. #3
    Join Date
    May 2003
    Posts
    369

    file not found

    I get file not found errors but the files are there.

  4. #4
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    put 'set -x' at the begining of the script and run - it should provide you the insight of what's being executed.
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

  5. #5
    Join Date
    May 2003
    Posts
    369

    update

    OK I resolved the file not found issue, now have new problem. Here is what I want to accomplish:

    create an array of all the files to loop thru
    take a diff of the files
    write the output to a .txt flat file in unix.

    what I have thus far: (old script)

    diff ${REPORT_DIR}_db_dy_${ORACLE_SID}_a.dat ${REPORT_DIR}_db_dy_${ORACLE_SID}_b.dat > diffs.txt

    I want to take these about 100 of these files and make an array and process all 100 of them in a ksh loop to separate reports in flat files. Can anyone help me with how to do this in a ksh script? Thanks!!

  6. #6
    Join Date
    Apr 2004
    Location
    Boston, MA
    Posts
    325
    how do you get the file listing?
    do you a file with all the files listed there OR do you simply 'ls' all the files in a given directory?

    I don't think you to use arrays - a simple iteration through the file listing will suffice.
    vlad
    +-----------------------+
    | #include <disclaimer.h> |
    +-----------------------+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •