Am 18.12.2010 00:24, schrieb Paolo Bonzini:
On 12/17/2010 11:17 PM, Andreas Färber wrote:
Example (needs bash's echo -e):

# create line with crlf ending:
echo -e 'include xy\r' >file

# returns xy\r:
awk '/^include / {ORS=" "; print $2}' file | od

0000000 074570 020015
0000004

# should return xy:
awk '/^include / {ORS=" "; sub(/\r$/, "", $2); print $2}' file | od

awk: syntax error near line 1
awk: illegal statement near line 1
0000000

Can you try \015 instead of \r?

Same.

Then I guess Stefan should use

tr -d '\015' < file | awk '/^include / {ORS=" "; print $2}'

or something like that.

Paolo


Andreas, please try this variant of Paolo's suggestion:

tr -d '\r' file | awk '/^include / {ORS=" "; print $2}' | od -c

I found some SunOS man pages online: tr should work with
'\r', and awk does not support the sub function (therefore
you always got a syntax error).

If the new code works, I'll send a modified patch.

Thanks,
Stefan


Reply via email to