[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] Re: Perl question



> 
> I have a 17 MB x,y asci data file that I am trying to plot with gnuplot, it doesn't want to plot
> and as this is the first time I have worked with files this size I am blaming the file size.  I
> want to reduce the size of the file or plot every 5th pair.  Is perl capable of running through the
> file and extracting every 5th pair or am I approaching this the wrong way?
> 

Awk will do the job in less lines (I imagine) :-) 

	awk 'NR % 5 == 1 { print $0 }' < input.file

Change the "5" to whatever interval you need. The "1" can be any number
between 0 and 4 (or whatever other interval you choose, minus 1) and just
defines /which/ line in each group of 5 to recover.

Chris...

ps, on a completely different note - your lines are longer than 80 chars,
which plays havoc when you read mail on a 80x24 terminal (like me, atm :-) );
can you have them wrap at ~76 chars ?

-- 
\ Chris Johnson           \
 \ cej [at] nightwolf.org.uk    ~-----,   
  \ http://cej.nightwolf.org.uk/  ~-----------------------------------, 
   \ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 \____
___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.