I need to have the same order of the keys similar to the file 1 in file 3.
please let me know the best way to generate the 3rd file either using awk or sed.
LA
< datafile awk '
BEGIN { FS="\t"
# get the very first key.
getline key < "keyfile" }
{
# If the data's ahead in order, read keys until you catch up
# but don't read keys past EOF.
while(key && (key < $1))
getline key < "keyfile"
if(key && (key == $1))
print;
}'
It can't be running out of room, it's not storing anything, so it's not related to the quantity of data. I think, either the keys or the data aren't in legographical order, or, the key file contains blank lines which would make it give up instantly.
Could you post the smallest possible sample of data that shows the problem?
I can't sort the key file as I need the file 3 to be generated and ordered in the same order. But I could sort the datafile. The main catch is to keep the same order in the output file as it is present in the key file
LA