I am new to AWK. I am trying to format names in a file named names.txt to output the names arranged in a certain way with some of them capitalized and then the output put into an HTML table. See below.
names.txt
KOVACS PETER
Kiss Roland
Nagy jolan
Lisztes Tibor
Feher aNDRas
Korma Maria
Akarki Jack
The output of the names after running the AWK should be as below.
Kovacs Peter Lisztes Tibor Akarki Jack
Kiss Roland Feher Andras
Nagy Jolan Korma Maria
Here is the AWK code I have written so far in my trial.awk file.
BEGIN{
FS=OFS=" ";
}{
s=tolower($0);
split (s, letters, " ");
array[arraylen++] = toupper( substr( letters[1], 1, 1 ) ) substr( letters[1], 2 ) " " toupper( substr( letters[2], 1, 1 ) ) substr( letters[2], 2 );
up=toupper(substr(s,1,1));
small=tolower(substr(s,1,1));
as=sub(/small/, up, s);
}
END{
r=0;
for(rows=1;rows<=3;rows++){
for(columns=r;columns<=r+6;columns+=3){
printf("%s \t ",array[columns]);
}r=r+1;
columns=r;
printf("\n");
}
}
I want to run it as below and redirect the output into an HTML file with each name in a separate table cell. The remaining part is putting the output in the HTML file otherwise the names are already arranged and capitalized as needed in the code above. Kindly help. Thank you. Let us do this. awk -f trial.awk names.txt > output.html
What is required is that the output from the code above is posted into an HTML file using AWK with each name in a separate cell. awk -f trial.awk names.txt > output.html