[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GAWK error : replace newline with tab in WinXP ?

From: Kam-Hung Soh
Subject: Re: GAWK error : replace newline with tab in WinXP ?
Date: Tue, 25 Mar 2008 19:11:54 -0700 (PDT)
User-agent: G2/1.0

On Mar 26, 2:50 am, John Bartley K7AAY <> wrote:
> awk 'ORS=%NR%1?",":"\t"' %1.tsv > %1.csv
> This line of code, adapted 
> from
> fails for me while running GNUWIN32 gawk 3.1.0  and I would appreciate
> guidance from y'all in finding a fix.
> I am trying to take a three line file and turn it into a one-line, tab-
> separated file, so I can (later on) concatenate multiple files into
> one CSV for import into Excel.
> Thank you kindly in advance.
> The TSV files look something like this:
> XY_12345_Acme_Blinder_Coughdrop-Optimal
> 9
> This test will run Lorem ipsum dolor sit amet, consectetuer adipiscing
> elit. Fusce a diam. Etiam sapien pede, placerat quis, malesuada in,
> eleifend quis, velit. Praesent imperdiet cursus odio. Praesent vel
> lorem. Pellentesque dignissim, felis non euismod rhoncus, felis pede
> condimentum lacus, ac accumsan mi leo sit amet lacus. Donec porta nunc
> ut sapien. Morbi pede. Nulla tincidunt nisi mollis augue. Praesent
> dapibus cursus tellus. Sed accumsan dui sed metus. Morbi lacus. Nunc
> placerat arcu tincidunt turpis. Proin tristique ullamcorper velit.
> Proin id justo egestas erat interdum volutpat. Sed sodales massa sit
> amet orci. Duis hendrerit volutpat velit. Aenean vel libero.
> Suspendisse potenti.##Test will run the following sequence:#1. Run in
> circles#2. Scream#3. And shout###The following are is a more in-depth
> look at what each of Praesent tincidunt egestas nulla. Nullam non mi.
> Ut tellus ipsum, molestie fringilla, eleifend non, pulvinar vel,
> sapien. Nullam et mi nec neque tempus iaculis. Sed quam. Aenean orci
> nulla, sodales et, pulvinar sodales, sagittis vel, turpis. Aliquam
> massa quam, porttitor vitae, rhoncus ac, volutpat at, sem. Cras sed
> lorem. Mauris faucibus erat non neque. Nunc bibendum mattis mi.
> Quisque elementum diam at lectus. (
> currentview.html) and the physics are using the collected wisdom of
> Fred on Everything (
> FOE_Frame_Column.htm).#The tests are run in Ut arcu. Nulla venenatis
> egestas risus. Vestibulum nec ligula. Aenean adipiscing risus quis
> libero vulputate rutrum. Proin sagittis orci non mi. Mauris magna.
> Aliquam malesuada lectus vitae pede. Integer lacus risus, volutpat
> sed, ultrices in, venenatis et, libero. Praesent euismod mauris id
> turpis hendrerit egestas. Mauris tristique. Aliquam vel enim posuere
> nisi vehicula laoreet. Integer tempus vestibulum odio. Donec et quam.
> Maecenas lacinia nulla sed est. Donec mollis ligula sed tellus.
> Phasellus quis eros a sem vulputate eleifend. Phasellus sagittis felis
> id tellus. Nunc condimentum ultricies sem. ##Test 1:# How many Aggies
> does it take to screw in a lightbulb? #Sed blandit, tellus non cursus
> blandit, est justo sollicitudin lectus, vel mollis lectus magna ac
> pede. Aliquam aliquam lorem sed erat. Quisque rutrum, enim sit amet
> ornare varius, dui libero lacinia orci, non iaculis mi sapien non
> urna. Sed massa ante, elementum ut, posuere quis, interdum eget,
> ipsum. Duis blandit condimentum elit. Aliquam volutpat iaculis leo.
> Suspendisse nibh nibh, dignissim cursus, elementum sed, convallis eu,
> metus. Phasellus vel magna. Aenean nulla nisi, rhoncus non, egestas
> non, commodo bibendum, pede. Aliquam justo. Aliquam sapien tortor,
> placerat accumsan, auctor porta, rhoncus sed, tortor. Ut tempus.
> Curabitur vitae lectus quis lectus venenatis posuere. Curabitur
> venenatis. Donec elementum eros. Praesent eget ligula nec metus
> molestie hendrerit. Sed at nisi.

When I tried your script on Windows XP using GNU Awk 3.1.3, I found
this error:

gawk: cmd. line:1: 'ORS=1?,:\t'
gawk: cmd. line:1: ^ invalid char ''' in expression

If that is the problem you encountered, you have to escape the double-
quote mark in a double-quoted string using the "^" (double-quote caret
double-quote) sequence.  (It's as awkward as it sounds.)


gawk "ORS=1?"^"","^"":"^""\t"^""" %1.tsv > %1.csv


Kam-Hung Soh <a href="";>Software Salariman</

reply via email to

[Prev in Thread] Current Thread [Next in Thread]