Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 10-15-2008, 05:42 AM   #1
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, 07:08 AM   #2
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.

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

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


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

All times are GMT -5. The time now is 09:22 PM.

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