put data from some files into a field
i have 3 files as below:
Code:
[file1][file2][file3] [output]: Code:
{line1}(field 1 of line 1 from file 1)(field 2 of line 1 from file 1)(field 5 of line 1 from file 1)(field 10 of line 1 from file 1)...(field 10 of line 5 from file 1) |
in perl you can easily open 3 files, split lines into fields and construct a line you need. What have you tried until now?
|
Quote:
Code:
#!/bin/bash Code:
lat lon depth RMS Gap SecGap MinDis MedDis MaxDis azMaxHorUnc MaxHorAnc MinHorAnc CovvXX CovvYY CovvZZ |
Assuming you mean {line1} .. {line3} literally, then
Code:
awk '(FNR==1) { if (files > 0) printf("\n"); Code:
awk '(FNR==1) { if (files++>0) SP="\n" } The (FNR<=5) rule is applied to first five lines of each input file. It outputs the first, second, fifth and tenth fields of the input line, but without a newline. (The latter one prepends no separator for the first line of first input file, a newline for the first line of any other input files, and a space for the second to fifth input lines of all input files.) Since the last output line does not get a newline, we add one in the END rule, but only if there have been input lines. Note that you can specify any number of files. If you don't specify any, then standard input is used (as the only file). |
All times are GMT -5. The time now is 05:48 PM. |