The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
simple while loop ali560045 Shell Programming and Scripting 10 12-26-2007 10:44 AM
simple for loop ali560045 Shell Programming and Scripting 3 12-17-2007 01:39 AM
Simple loop query kutz13 UNIX for Dummies Questions & Answers 2 07-17-2007 04:13 PM
Simple while loop question Brokeback Shell Programming and Scripting 3 07-21-2006 10:04 AM
a simple while loop syno Shell Programming and Scripting 5 04-08-2006 07:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-21-2008
dsstamps dsstamps is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 3
a simple loop in csh

Hello,

I have a file with over 48000 lines and I need to select certain parts of the file. I know which awk commands work for what I need, I just need some help putting together a loop that will repeat the command. These are the commands that work:

awk 'NR < 6' plot.out > plot.test (I get the first 5 lines of plot.out)

awk 'NR==15,NR==17' plot.out >> plot.test (now I need these lines)
awk 'NR==30,NR==32' plot.out >> plot.test (etc.)
awk 'NR==45,NR==47' plot.out >> plot.test
awk 'NR==60,NR==62' plot.out >> plot.test
awk 'NR==75,NR==77' plot.out >> plot.test
awk 'NR==90,NR==92' plot.out >> plot.test
awk 'NR==105,NR==107' plot.out >> plot.test
awk 'NR==120,NR==122' plot.out >> plot.test
awk 'NR==135,NR==137' plot.out >> plot.test


Please help. All the loops I make don't work I know this is simple for somebody out there.....
  #2 (permalink)  
Old 05-22-2008
elthox elthox is offline
Registered User
  
 

Join Date: Dec 2006
Posts: 30
Quote:
Originally Posted by dsstamps View Post
Hello,

I have a file with over 48000 lines and I need to select certain parts of the file. I know which awk commands work for what I need, I just need some help putting together a loop that will repeat the command. These are the commands that work:

awk 'NR < 6' plot.out > plot.test (I get the first 5 lines of plot.out)

awk 'NR==15,NR==17' plot.out >> plot.test (now I need these lines)
awk 'NR==30,NR==32' plot.out >> plot.test (etc.)
awk 'NR==45,NR==47' plot.out >> plot.test
awk 'NR==60,NR==62' plot.out >> plot.test
awk 'NR==75,NR==77' plot.out >> plot.test
awk 'NR==90,NR==92' plot.out >> plot.test
awk 'NR==105,NR==107' plot.out >> plot.test
awk 'NR==120,NR==122' plot.out >> plot.test
awk 'NR==135,NR==137' plot.out >> plot.test


Please help. All the loops I make don't work I know this is simple for somebody out there.....


I see that NR is incremented by 15

cat plot.out|awk -v x=15 'NR==x,NR==x+2 {x=x+15};END{print $0}'
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0