Pls help me out wid below prblm :
i have 5 files A,B,C,D and E located at /home/anubha
I have a file F located at /home/anubha/ed
File F has some records which can be matched in A,B,C,D and E
and another set of files on the basis of these filteration should be created i.e. G,H,I,J and K to be stored at /home/anubha/priya
Plsss help me out....pls pls pls..pls pls pls...:wall::wall:
I created below script for the same but it is just creating the files at locations not having any data in it....can you ppl plz lemme kno whr am i making mistakE???:(:(:(:(:(
##filter.sh
#!/bin/bash
. anusha.sh
#we will use shell script to create these filter files as well
for file in `ls -1 ${SRC_DIR}/*.EDW`
do
filename=`basename $file`
#echo "FILE NAME -" $filename
grep -e ${IMSI_FILTER} ${file} >> ${TEMP_LOAD_DIR}
done
A,B,E are having 10 columns one of which is msisdn...
filter files F is having a list of msisdn...on the basis of F;A,B,C,D and E will be picked up with relevant rows and should be written as G,H and K..
---------- Post updated at 04:17 AM ---------- Previous update was at 04:14 AM ----------
A,B,E are having 10 columns one of which is msisdn...
filter files F is having a list of msisdn...on the basis of F;A,B,C,D and E will be picked up with relevant rows and should be written as G,H and K..
also below are the examples of the files i am taking into consideration :
F
The awk code can also easyly be adapted to handle better the naming and the location of the target file i just did a quick shot here.
I haven't tried it so it may require some fix but you can give a try to the following
cd /home/anubha
awk 'BEGIN{n=split("ABCDEGHIJK",b,"");d="/home/anubha/priya"}
NR==FNR{a[$1];next}
FNR==1{for(i=0;++i<=n/2;) if(b==FILENAME) {t=d "/" b[i+5];break}}($1 in a){print $0 > t}' ./ed/F A B C D E
i use some crap version of linux....which doesnt hv sed/awk plugin installed in it....i dunno bt code doesnt wrk wid sed/awk...cn u suggst wid grep or fgrep... :o