LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-28-2003, 09:55 AM   #1
realos
Member
 
Registered: Jul 2002
Location: Germany
Distribution: Redhat 7.3, Debian 3.1, Knoppix 3.1, Ubuntu 6.10
Posts: 113

Rep: Reputation: 15
FS=? in gawk


hi,
I am having some stupid problem with regular expressions in gawk.

me@pc> gawk -f test.awk test.log
does not find print anything on stdout.


..............test.awk .................
/^DESCRIPTION$/ {print "test passed!"}


.................EOF ............................
.................test.log....................
DESCRIPTION 123


................EOF.....................

Can any one help? Since FS seperates fieds after a blank space there should not be any need of resetting it.


man page revels following:

^ ......matches the beginning of a sting
$ ......matches the end of a string
FS ......the input field seperator, a space by default,


thanks for any idea,
 
Old 05-28-2003, 03:46 PM   #2
vladkrack
Member
 
Registered: Oct 2002
Location: Curitiba - Brazil
Distribution: Conectiva
Posts: 334

Rep: Reputation: 30
The problem is that in you are testing if the string has only the word "DESCRIPTION" in the line (start the line, has the word, finish the line). You can test the test.awk without the $ (end of the line), and then the test will pass...
 
Old 05-28-2003, 07:30 PM   #3
realos
Member
 
Registered: Jul 2002
Location: Germany
Distribution: Redhat 7.3, Debian 3.1, Knoppix 3.1, Ubuntu 6.10
Posts: 113

Original Poster
Rep: Reputation: 15
vladkrack,

Okay, I got it. Strings are equal to records (=lines) and not fields (words). That is why i tried to use /^DESCRIPTION$/.

I have a logfile like here:
---------------------------test.log-----------------
{white_space_not_visible_here} DESCRIPTION
{white_space}xx
{white_pace}SOME_DESCRIPTION_X
-------------------------------------------------------

Only the first DESCRIPTION should cause an action to take place. Well, with /^[ \t]*DESCRIPTION$/ it is working fine.

thanks,

Last edited by realos; 06-16-2003 at 06:37 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
where is curl and gawk ???????? bozart ROCK 11 10-23-2005 10:41 PM
Eh? A 'gcc' dependency in 'gawk'? sundialsvcs Linux From Scratch 3 07-27-2005 08:55 PM
Gawk won't configure correctly microsoft/linux Linux From Scratch 1 07-13-2005 01:37 PM
Gawk and Apt-get Problem saltas Debian 9 09-28-2004 07:06 PM
gawk question luxpops Programming 1 09-12-2004 04:46 AM


All times are GMT -5. The time now is 01:46 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration