Hello Guys,
I would like to concatenate all the line of a file in a String.
So I created this awk command :
gawk 'BEGIN{texte=""}{texte=(texte ", " $0); print length(texte);}END{print " -- "texte "--"; print length(texte)}' listvip.properties
But I have a strange result.
It seems AWK concatenate the strings in one.
But it does not display the correct value, AWK retrun only the last line. But when I used length on the variable texte, I see the actual lentght is greater that what has been display.
Any Solution ?
Best Regards
Abdou
I would like to concatenate all the line of a file in a String.
So I created this awk command :
gawk 'BEGIN{texte=""}{texte=(texte ", " $0); print length(texte);}END{print " -- "texte "--"; print length(texte)}' listvip.properties
But I have a strange result.
It seems AWK concatenate the strings in one.
But it does not display the correct value, AWK retrun only the last line. But when I used length on the variable texte, I see the actual lentght
is greater that what has been display.
Hello Guys,
I would like to concatenate all the line of a file in a String.
So I created this awk command :
gawk 'BEGIN{texte=""}{texte=(texte ", " $0); print length(texte);}END{print " -- "texte "--"; print length(texte)}' listvip.properties
But I have a strange result.
It seems AWK concatenate the strings in one.
But it does not display the correct value, AWK retrun only the last line.
But when I used length on the variable texte, I see the actual lentght is greater that what has been display.
Any Solution ?
Best Regards
Abdou
El 23/03/2022 a las 12:04, Abdou B escribió:--- Synchronet 3.19c-Linux NewsLink 1.113
Hello Guys,
I would like to concatenate all the line of a file in a String.
So I created this awk command :
gawk 'BEGIN{texte=""}{texte=(texte ", " $0); print length(texte);}END{print " -- "texte "--"; print length(texte)}' listvip.properties
But I have a strange result.It works OK in my system. No problem.
It seems AWK concatenate the strings in one.If lines are terminated by CR+LF and the CR char is kept as the final
But it does not display the correct value, AWK retrun only the last line.
char of each line, then what is printed en the screen will have the text lines overprinted.
But when I used length on the variable texte, I see the actual lentght is greater that what has been display.A LOCALE problem? Please test:
LC_ALL=C gawk .....
And see if it makes a difference.
Any Solution ?
Best Regards
Abdou
--
Manuel Collado - http://mcollado.z15.es
The dos2unix on my files made it work
Many Thanks to all !
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 829 |
Nodes: | 10 (0 / 10) |
Uptime: | 112:45:38 |
Calls: | 11,468 |
Calls today: | 7 |
Files: | 186,240 |
Messages: | 1,815,067 |