If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > using an array and loop to take diffs

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-13-04, 12:52
mixxalot mixxalot is offline
Registered User
 
Join Date: May 2003
Posts: 369
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
Reply With Quote
  #2 (permalink)  
Old 12-13-04, 14:00
vgersh99 vgersh99 is offline
Registered User
 
Join Date: Apr 2004
Location: Boston, MA
Posts: 325
what kind of errors?
__________________
vlad
+-----------------------+
| #include <disclaimer.h> |
+-----------------------+
Reply With Quote
  #3 (permalink)  
Old 12-13-04, 15:11
mixxalot mixxalot is offline
Registered User
 
Join Date: May 2003
Posts: 369
file not found

I get file not found errors but the files are there.
Reply With Quote
  #4 (permalink)  
Old 12-13-04, 15:16
vgersh99 vgersh99 is offline
Registered User
 
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> |
+-----------------------+
Reply With Quote
  #5 (permalink)  
Old 12-13-04, 15:54
mixxalot mixxalot is offline
Registered User
 
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!!
Reply With Quote
  #6 (permalink)  
Old 12-14-04, 09:19
vgersh99 vgersh99 is offline
Registered User
 
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> |
+-----------------------+
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On