El 23/03/2022 a las 12:04, Abdou B escribió:
> 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.
> But it does not display the correct value, AWK retrun only the last line.
If lines are terminated by CR+LF and the CR char is kept as the final
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