Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

awk: syntax error near line 1 awk: bailing out near line 1

875 views
Skip to first unread message

ramku...@gmail.com

unread,
Aug 27, 2008, 3:02:14 AM8/27/08
to
hi,

i am trying to reflect the name (example: LDRIVE in to RDRIVE) in UNIX
sun environment and please find below the script i used.

awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1),
"[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and
(match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) =
%s (unchanged)\n", length(substr($2,2)), NR, substr($2,2); else if
(substr($2,2,1) == "R") printf "(VNAME 1 %d, %6d ) = L%s (was %s)\n",
length(substr($2,2)), NR, substr($2,3), substr($2,2); else if
(substr($2,2,1) == "L") printf "(VNAME 1 %d, %6d ) = R%s (was %s)\n",
length(substr($2,2)), NR, substr($2,3), substr($2,2); else if
( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R")
printf "(VNAME 1 %d, %6d ) = %sL%s (was %s)\n", length(substr($2,2)),
NR, substr($2,2,1), substr($2,4), substr($2,2); else if
(substr($2,3,1) == "L") printf "(VNAME 1 %d, %6d ) = %sR%s (was %s)
\n", length(substr($2,2)), NR, substr($2,2,1), substr($2,4),
substr($2,2)}' gridnames


awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1),
"[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and
(match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) = %s
\n", length(substr($2,2)), NR, substr($2,2); else if (substr($2,2,1)
== "R") printf "(VNAME 1 %d, %6d ) = L%s\n", length(substr($2,2)), NR,
substr($2,3); else if (substr($2,2,1) == "L") printf "(VNAME 1 %d,
%6d ) = R%s\n", length(substr($2,2)), NR, substr($2,3); else if
( match(substr($2,2,1), "[FfCcAa]") == 1 ) if (substr($2,3,1) == "R")
printf "(VNAME 1 %d, %6d ) = %sL%s\n", length(substr($2,2)), NR,
substr($2,2,1), substr($2,4); else if (substr($2,3,1) == "L") printf
"(VNAME 1 %d, %6d ) = %sR%s\n", length(substr($2,2)), NR,
substr($2,2,1), substr($2,4)}' gridnames >> piok.in2

the following error is coming when i execute:

awk: syntax error near line 1
awk: bailing out near line 1
awk: syntax error near line 1
awk: bailing out near line 1

can any one help in shorting out

thanks

ravi

Janis Papanagnou

unread,
Aug 27, 2008, 3:19:33 AM8/27/08
to

Just a note...

It is possible to put awk programs in a file, say "trash.awk", and
call it as...

awk -f trash.awk datafiles

Then you can also format your code (for free; no extra fee) to become
readable by using a single command per line and proper indentation.
Doing that will greatly increase the number of people who are willing
to analyse your code. Having an awk program of many lines might also
point you to the line number of your problem without necessity to ask
here.

Are you working on solaris? Try /usr/xpg4/bin/awk instead of /bin/awk.

Janis

>
> thanks
>
> ravi

Grant

unread,
Aug 27, 2008, 3:41:35 AM8/27/08
to
On Wed, 27 Aug 2008 00:02:14 -0700 (PDT), ramku...@gmail.com wrote:

>hi,
>
>i am trying to reflect the name (example: LDRIVE in to RDRIVE) in UNIX
>sun environment and please find below the script i used.
>
>awk -F ">" '{if (substr($2,2,1) != " ") if ((match(substr($2,2,1),
>"[RL]") != 1) and !((match(substr($2,2,1), "[FCA]") == 1) and
>(match(substr($2,3,1), "[RL]") == 1))) printf "(VNAME 1 %d, %6d ) =
>%s (unchanged)\n", length(substr($2,2)), NR, substr($2,2); else if
>(substr($2,2,1) == "R") printf "(VNAME 1 %d, %6d ) = L%s (was %s)\n",
>length(substr($2,2)), NR, substr($2,3), substr($2,2); else if
>(substr($2,2,1) == "L") printf "(VNAME 1 %d, %6d ) = R%s (was %s)\n",

What ever happened to whitespace and structure?

Grant.
--
http://bugsplatter.id.au/

Michael Tosch

unread,
Aug 27, 2008, 3:34:27 PM8/27/08
to

Try nawk or /usr/xpg4/bin/awk rather than /bin/awk.
At least you'll get a better error message.


--
echo imhcea\.lophc.tcs.hmo |
sed 's2\(....\)\(.\{5\}\)2\2\122;s1\(.\)\(.\)1\2\11g;1s;\.;::;2'

jeanph...@googlemail.com

unread,
Aug 27, 2008, 5:12:44 PM8/27/08
to
On Aug 27, 9:34 pm, Michael Tosch <eed...@NO.eed.SPAM.ericsson.PLS.se>
wrote:
> sed 's2\(....\)\(.\{5\}\)2\2\122;s1\(.\)\(.\)1\2\11g;1s;\.;::;2'- Hide quoted text -
>
> - Show quoted text -

Hi,

In addition to Janis'recommendations, you'd gain in readability if you
were storing function results into intermediary variables.

Anyway, I think the errors arise from the fact that "and" is not the
right logical conjunction operator. You'd rather use "&&".

Hope it helps.

Cheers,

Jean-Philippe

ramku...@gmail.com

unread,
Aug 28, 2008, 1:35:07 AM8/28/08
to
On Aug 27, 7:19 am, Janis Papanagnou <janis_papanag...@hotmail.com>
wrote:


Greetings and thanks for your effort.

when i execute the above script in hp workstation it is working fine
but in the sun machine it is not working. can you guide me to short
out from the below error:

awk: syntax error near line 1
awk: bailing out near line 1
awk: syntax error near line 1
awk: bailing out near line 1

thanks

ravi

Janis Papanagnou

unread,
Aug 28, 2008, 2:25:25 AM8/28/08
to

As said, instead of...

awk -F ">" '...'

try

/usr/xpg4/bin/awk -F ">" '...'

or reformat your code to make it legible for an analysis.

Janis

Maxwell Lol

unread,
Sep 1, 2008, 8:07:29 PM9/1/08
to
ramku...@gmail.com writes:

> Greetings and thanks for your effort.
>
> when i execute the above script in hp workstation it is working fine
> but in the sun machine it is not working. can you guide me to short
> out from the below error:
>
> awk: syntax error near line 1
> awk: bailing out near line 1
> awk: syntax error near line 1
> awk: bailing out near line 1

Don't use awk. Use nawk. This is new awk.
Both ar on the SOlaris OS.
There are many many reasons to use the new awk.
Reason #1 - better error messages.

Ed Morton

unread,
Sep 2, 2008, 8:31:15 AM9/2/08
to
On 9/1/2008 7:07 PM, Maxwell Lol wrote:
> ramku...@gmail.com writes:
>
>
>>Greetings and thanks for your effort.
>>
>>when i execute the above script in hp workstation it is working fine
>>but in the sun machine it is not working. can you guide me to short
>>out from the below error:
>>
>>awk: syntax error near line 1
>>awk: bailing out near line 1
>>awk: syntax error near line 1
>>awk: bailing out near line 1
>
>
> Don't use awk. Use nawk. This is new awk.

Or /usr/xpg4/bin/awk. Just don't use old, broken awk.

> Both ar on the SOlaris OS.
> There are many many reasons to use the new awk.
> Reason #1 - better error messages.

Reason #1 - fewer error messages ;-).

Ed.


Kenny McCormack

unread,
Sep 2, 2008, 9:16:16 AM9/2/08
to
In article <48BD3213...@lsupcaemnt.com>,

Ed Morton <mor...@lsupcaemnt.com> wrote:
>On 9/1/2008 7:07 PM, Maxwell Lol wrote:
>> ramku...@gmail.com writes:
>>
>>
>>>Greetings and thanks for your effort.
>>>
>>>when i execute the above script in hp workstation it is working fine
>>>but in the sun machine it is not working. can you guide me to short
>>>out from the below error:
>>>
>>>awk: syntax error near line 1
>>>awk: bailing out near line 1
>>>awk: syntax error near line 1
>>>awk: bailing out near line 1
>>
>>
>> Don't use awk. Use nawk. This is new awk.
>
>Or /usr/xpg4/bin/awk. Just don't use old, broken awk.

Why do people give this crappy advice? Both nawk and xpg4awk are just
somewhat better (read: not terrible) than Solaris:binawk.

If you're going to go non-standard (don't bother to argue with this; you
know what I mean), just get GAWK and be happy.

>> Both ar on the SOlaris OS.
>> There are many many reasons to use the new awk.
>> Reason #1 - better error messages.
>
>Reason #1 - fewer error messages ;-).
>
> Ed.

Yes. That should be:

Reason #1 - fewer error messages

Reason #2 - better error messages

Ed Morton

unread,
Sep 2, 2008, 9:24:07 AM9/2/08
to
On 9/2/2008 8:16 AM, Kenny McCormack wrote:
> In article <48BD3213...@lsupcaemnt.com>,
> Ed Morton <mor...@lsupcaemnt.com> wrote:
>
>>On 9/1/2008 7:07 PM, Maxwell Lol wrote:
>>
>>>ramku...@gmail.com writes:
<snip>

>>>>awk: syntax error near line 1
>>>>awk: bailing out near line 1
>>>>awk: syntax error near line 1
>>>>awk: bailing out near line 1
>>>
>>>
>>>Don't use awk. Use nawk. This is new awk.
>>
>>Or /usr/xpg4/bin/awk. Just don't use old, broken awk.
>
>
> Why do people give this crappy advice? Both nawk and xpg4awk are just
> somewhat better (read: not terrible) than Solaris:binawk.

No, there's a significant difference in usability between old, broken awk and
any modern awk (/usr/xpg4/bin/awk, nawk, gawk, etc.). All the modern awks are
usable, there's just relatively small differences in functionality between them
with gawk having the most extensions.

>
> If you're going to go non-standard (don't bother to argue with this; you
> know what I mean), just get GAWK and be happy.

I agree everyone should use gawk if possible but you can get by with any other
modern awk, it'll just be a little harder to get some jobs done.

Ed.

Old Man

unread,
Sep 2, 2008, 12:25:22 PM9/2/08
to

Your reply brings haunting memories from my past. In a
situation where I had the root password and "full" control
over a system, your advice to "get gawk" is good. However,
the real world of a policy and moreso, a politicer in the
admin group over the systems, getting anything is not an
option.

I took the reply to say, "using what is available on the
system as it has been configured by those in power ..."

Old Man

Michael Tosch

unread,
Sep 2, 2008, 2:04:31 PM9/2/08
to

Hi Old Man, it's time to upgrade to New Man.

Reason #1 - fewer fatalistic messages

Chris F.A. Johnson

unread,
Sep 2, 2008, 2:08:40 PM9/2/08
to
On 2008-09-02, Kenny McCormack wrote:
> In article <48BD3213...@lsupcaemnt.com>,
> Ed Morton <mor...@lsupcaemnt.com> wrote:
>>On 9/1/2008 7:07 PM, Maxwell Lol wrote:
>>> ramku...@gmail.com writes:
>>>
>>>>Greetings and thanks for your effort.
>>>>
>>>>when i execute the above script in hp workstation it is working fine
>>>>but in the sun machine it is not working. can you guide me to short
>>>>out from the below error:
>>>>
>>>>awk: syntax error near line 1
>>>>awk: bailing out near line 1
>>>>awk: syntax error near line 1
>>>>awk: bailing out near line 1
>>>
>>>
>>> Don't use awk. Use nawk. This is new awk.
>>
>>Or /usr/xpg4/bin/awk. Just don't use old, broken awk.
>
> Why do people give this crappy advice? Both nawk and xpg4awk are just
> somewhat better (read: not terrible) than Solaris:binawk.

nawk and /usr/xpg4/bin/awk implement the Awk Programming Language,
as defined in the book of that name. It is a vast improvement over
the old (i.e., pre-1988) awk.

Gawk offers a few unimportant extensions, most of which are rarely
necessary.

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence

Kenny McCormack

unread,
Sep 2, 2008, 2:26:48 PM9/2/08
to
In article <50fc8$48bd8128$cef88ba3$34...@TEKSAVVY.COM>,
Chris F.A. Johnson <cfajo...@gmail.com> humorously opined, in the
style of the SNL "angry old man":
...

> nawk and /usr/xpg4/bin/awk implement the Awk Programming Language,
> as defined in the book of that name. It is a vast improvement over
> the old (i.e., pre-1988) awk.
>
> Gawk offers a few unimportant extensions, most of which are rarely
> necessary.

Very funny. Proves the art of satire is not dead.

Good show.

James Kanze

unread,
Sep 3, 2008, 6:02:52 AM9/3/08
to
On Sep 2, 8:08 pm, "Chris F.A. Johnson" <cfajohn...@gmail.com> wrote:
> On 2008-09-02, Kenny McCormack wrote:
> > In article <48BD3213.9030...@lsupcaemnt.com>,

> > Ed Morton <mor...@lsupcaemnt.com> wrote:
> >>On 9/1/2008 7:07 PM, Maxwell Lol wrote:
> >>> ramkumar...@gmail.com writes:

[...]


> >>> Don't use awk. Use nawk. This is new awk.

> >>Or /usr/xpg4/bin/awk. Just don't use old, broken awk.

> > Why do people give this crappy advice? Both nawk and
> > xpg4awk are just somewhat better (read: not terrible) than
> > Solaris:binawk.

> nawk and /usr/xpg4/bin/awk implement the Awk Programming Language,
> as defined in the book of that name. It is a vast improvement over
> the old (i.e., pre-1988) awk.

I've had at least one case where /usr/xpg4/bin/awk accepted my
code, but nawk didn't.

In general, if you're working under Solaris, you should have
/usr/xpg4/bin in your path, before /usr/bin, so just awk will
get you the good one. (More generally, you should have:
` getconf PATH `
somewhere in your $PATH if you want a conformant environment.)

> Gawk offers a few unimportant extensions, most of which are rarely
> necessary.

And some of which introduce new keywords, which may break your
code. If all you've got is gawk, then you should invoke it as
"gawk --posix" (but in practice, this is only very occasionally
a problem).

--
James Kanze (GABI Software) email:james...@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

0 new messages