Date: Tue, 5 Feb 2002 00:36:54 -0800 (Pacific Standard Time) From: Joseph Stein <joes@joescanner.com> To: freebsd-questions@freebsd.org Subject: awk- make that sed- question Message-ID: <Pine.WNT.4.42.0202050029330.1444-100000@hood.wstein.com>
next in thread | raw e-mail | index | archive | help
Apologies if this is not the appropriate forum for this, but... An interesting problem. I am massaging some "strangely" formatted text output using sed and awk. The problem I am encountering is that some output lines are longer than 256 characters. I originally thought I was running into a problem in awk, but it turns out that the data lines are being truncated by sed. I find no mention of a maximum line length in the manual page for sed, and I'm sure there is a way to defeat the problem. The sed/awk pipeline I'm using looks like this: sed -e 's/"//g' -e 's/;/,/g' -e 's/\(<0[0-9A-F][0-9A-F][0-9A-F]\),/\1:/g' -e 's/\([0-9]\),\([0-9]\)/\1\2/' filename | awk ' { FS="," ; printf "\n%s\n", NF; print length($0); for (i=0; i<=NF; i++) print i ": " $i; print $NF; } ' While I realize this is pretty ugly, it does what I need: * remove all double quotes from input * replace ; with , * change a comma in data that looks like <0372, 1123> to a colon * remove the thousands separator in a number (231,445 => 231445) The awk script is not exactly what I want right this second, but it presents the data in the format I wish it to (almost) and I can tweak that myself. Any ideas? joe --- Joseph Stein (KD7MLG) joes at joescanner dot com Beaverton, OR USA To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.WNT.4.42.0202050029330.1444-100000>