LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-14-2012, 08:54 AM   #1
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Error while using awk: Unmatched '.


Hello,
While running awk directly on terminal (not in any script), I am getting an error (I guess it's very common) if I try to use multi-liner awk code:
Code:
# nawk 'BEGIN{
Unmatched '.
OR
# /usr/xpg4/bin/awk 'BEGIN{
Unmatched '.
OR
# awk '
Unmatched '.
It appears all the time with all users I tried and on all distros! Since there's no pb with if I run a one-liner command:
Code:
example# awk 'BEGIN{FS=" "}; /string/ {gsub(/string/,"",$0); print $0}' infile
But if I try:
Code:
example# awk 'BEGIN{
Unmatched '.
 
Old 12-14-2012, 09:30 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Are you using a bash or (t)csh shell?

I do believe a (t)csh shell throws that error, while bash does not.

You can do the following in both shells:
Code:
awk 'BEGIN{ \
That is a space followed by a backslash with nothing after the backslash.
 
1 members found this post helpful.
Old 12-14-2012, 09:38 AM   #3
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
I can't reproduce your problem with nawk (or with gawk) with the example line you've given. Perhaps a section of your infile, say 10 or 20 lines would help diagnose?

A thought: you may have unmatched quotes in your file.

A other thought: shouldn't matter ('cause nawk doesn't care about such things) but try inserting spaces; e.g.,
Code:
nawk 'BEGIN { FS=" " } /string/ {gsub(/string/,"",$0); print $0}' infile
Still another thought: is your line too long for the terminal window (probably not, but ya never know, might be getting truncated).

Yet another thought: try it in KornShell instead of C-Shell.

Hope this helps some.
 
Old 12-14-2012, 11:50 AM   #4
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800

Original Poster
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
You're right @druuna! I was also doubtful with execution shell.
This is a pb with tcsh and traditional /sbin/sh. But worked fine with bash.
Thanks everyone!
 
  


Reply

Tags
awk



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk error awk: line 2: missing } near end of file boscop Linux - Networking 2 04-08-2012 10:49 AM
[SOLVED] find cp xargs and error unmatched single quote; mythcat Linux - Newbie 6 01-23-2012 11:11 AM
[SOLVED] action on unmatched pattern - awk sopier Programming 5 12-13-2011 07:31 PM
Porting ksh script from Solaris to Linux Gives unmatched if error markatharvestinfotec Programming 4 08-28-2008 01:51 PM
boot problem. after "INIT: version 2.85 booting: awk: fatal: Unmatched ( dobreman Fedora 2 05-27-2006 11:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration