hi friends,,,

I have two type of files one .txt format another one is .idx format..

txt file have 7 columns delimited with "|"

idx file have 7 columns demilited with ","

i have to compare the txt file 2nd and 3rd column with idx 3rd and 4th column.

Here is my script :

if [ $# != 2 ]
then
echo "Usage: $0 <Comma Seperated File(.IDX)> <Pipe Seperated File (.TXT)>"
exit
fi
fname=`ls $1 |awk -F"/" '{print $NF}' |cut -d "." -f1`
mkdir .temp_as_$fname;

awk -F"," '{print $3 "|" $4 }' $1 |sort -u > .temp_as_$fname/IDX_File
awk -F"|" '{print $3 FS $4}' $2 |sort -u > .temp_as_$fname/TXT_File

comm -23 .temp_as_$fname/TXT_File .temp_as_$fname/IDX_File > .temp_as_$fname/IDX_Issue.txt
comm -13 .temp_as_$fname/TXT_File .temp_as_$fname/IDX_File > .temp_as_$fname/TXT_Issue.txt

Am having 250 number of idx and txt files.. so that i have to run both number of files and getting 250 output files.. so i want to get only one output file.. and 250 files should be stored in array..
how to do this... guide me..:?:

I didn't really get what you wanna do, stupid it may sound but if what you want all 250 .temp_as_$fname/IDX_Issue.txt and .temp_as_$fname/TXT_Issue.txt files concatenated into one single file (or 2 files) you can do this:

for f in .temp_as_*/TXT_Issue.txt
do
echo '-----------------------------------' >> ./consolidated_TXT_file.txt
cat $f >> ./consolidated_TXT_file.txt
done
#do the same for IDX

OR

for f in .temp_as_*/TXT_Issue.txt .temp_as_*/IDX_Issue.txt
do
echo '-----------------------------------' >> ./consolidated_TXT-IDX_file.txt
cat $f >> ./consolidated_TXT-IDX_file.txt
done
This article has been dead for over six months. Start a new discussion instead.