Quote:
Originally Posted by
znesotomayor
Hi Sir Don,
If it's empty character or tab delimeted. hmm.. Is it possible to put the field 1 and field 2 of file 2 into field 6 and 7? all i want is to put the data of field 1 and field 2 of file2.txt on file1.txt if Field 4 of file1.txt = Field 3 of file2.txt
Please advise,
Thanks,
From your first post in this thread:
Quote:
Condition
If Field 4 of file1.txt = Field 3 of file2.txt, the value of Field 1(canada) and Field 2(jap) of file2.txt will be put on Field 2 and Field 3 of file1.txt
To meet your condition, we first have to be able to identify what is in Field 4 of
file1.txt. And, when your field separator is a variable number of spaces, there is no way to determine whether the 2nd line in your sample
file1.txt contains fields 1 and 2, 1 and 3, 1 and 4, 2 and 3, 2 and 4, or 3 and 4. With its default field separator, the
awk utility will assume that that line contains fields 1 and 2 and that fields 3 and 4 are empty strings.
If your fields each contained a fixed number of characters, we could identify fields by character counts; but the data in your sample files does not line up with the headers, so we can't do that.
If your fields used a single <tab> character as a field separator instead of a seemingly random number of <space> characters, we could identify field boundaries easily; but the data in your sample files does not use <tab> characters; it uses a seeming random number of <space> characters.
I repeat: With no way to determine field boundaries in your input data when some fields are empty, there is no way to determine what is in field 4. So if you want to make decisions based on what is in field 4, you are out of luck.
Come up with an unambiguous input file format (and make sure your input files adhere to that format), tell us what that unambiguous input file format is, and show us sample input files in that format and the output you are trying to produce in that format and we may be able to help you come up with a reliable solution to your problem. If you can't do that, there isn't much we can do to help.