Hi ,
I am executing 2 queries and output is saved in file1.txt and file2.txt
example of file1.txt
Testing word Doc.docx,/Lab/Development and Validation/Multitest/MT_010708/Testing,Development and Validation,root,11-Mar-2014,,,,,
Testing Excel _.xlsx,/Lab/Development and Validation/Multitest/MT_010708/Testing,Development and Validation,root,11-Mar-2014,,,,,
example of file2.txt
Testing Excel _.xlsx,,,,,b,20653
Testing word Doc.docx,,,,,a,20653
Expected output:file3.txt
Testing word Doc.docx,/Lab/Development and Validation/Multitest/MT_010708/Testing,Development and Validation,root,11-Mar-2014,,,,,,,,,,a,20653
Testing Excel _.xlsx,/Lab/Development and Validation/Multitest/MT_010708/Testing,Development and Validation,root,11-Mar-2014,,,,,,,,,,b,20653
Now I want to merge file1.txt and file2.txt into file3.txt using following code with the help of name highlighted above which is common in both files and appears in the begining of line.
while read line
do
file_met_name=`echo $line | cut -d ',' -f1`
met_line_2 =` grep "$file_met_name,",file2.txt | cut -d ',' -f2-`
echo "$line","$met_line_2" >> file3.txt
done < file1.txt
Problem faced: If $file_met_name has string with multiple spaces as in "Testing word Doc.docx" the above code is not able to provide required output.