Assuming that the output of your loop is a
and the file is b
, this would
awk -F: 'NR==FNR { split($0,a,","); next }
{
s= a[1] " (" $2 ")"
for(i=2; i<=length(a); ++i) s=s "," a[i]
print s
}' a b
This processes the two inputs one line at a time. The first block is executed on the first input (because NR==FNR
) and the next
skips to the next input. The second block sandwiches the part from the second input into the first input.
output:
- Type TYPEN1 (TRANSCON1), Quantième du jour de réception 126, Nombre de lignes du fichier 6, Nom du fichier Test.txt
There is an assumption made here, that the lines from both inputs will be in the correct order (easy to fix using sort
) and there won't be any lines missing. Let me know if that's a problem.