LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 10-15-2008, 04:42 AM   #1
cliffoij
LQ Newbie
 
Registered: Jul 2007
Posts: 10

Rep: Reputation: 0
AWK- processing data inside start/stop pairs but ignoring start/stop lines


Hi all

I would like to know how to perform a small task in AWK. I'm able to extract data from a text file using "awk '/start/,/stop/'" all fine - I now wish to process the data further from the extract using AWK but ignoring the start/stop pair used to define the data set.

.
Start of text
line1 word1 word2
line2 word1 word2
End of Text

Is this possible please - any ideas ? Using the start/stop pair thereby inclus the first and last lines in the output, which I don't wish to process.

Cheers - Ian
 
Old 10-15-2008, 06:08 AM   #2
burschik
Member
 
Registered: Jul 2008
Posts: 159

Rep: Reputation: 31
You can check whether the line matches the start or stop pattern. If so, do nothing. Else continue with whatever you need to do.

Code:
awk '/b/, /d/ {if ($0 ~ /b/ || $0 ~ /d/) {} else {print;}}'
 
Old 10-15-2008, 06:17 AM   #3
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 66
Something like that maybe:
Code:
awk '
/Start of text/ {
  process="true"
  next
}
/End of text/ {
  process=""
  next
}
process=="true" {
  ...do what you have to do...
}'
Yves.
 
  


Reply



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
start, stop services johnkalikavunkal Solaris / OpenSolaris 1 07-14-2008 04:43 AM
Computer doesn't start; fans start then stop; 1 long, 1 short beep PatrickMay16 General 18 09-26-2007 07:48 PM
Samba Won't start or stop SBFree Linux - Newbie 1 12-28-2005 08:08 AM
how can i start, stop or restart Paxmaster Slackware 3 11-27-2004 01:31 PM
Start/stop services on start-up koyi Slackware 5 08-04-2003 08:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:27 PM.

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