Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old November 18th, 2005, 03:36 AM
bspatil bspatil is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 6 bspatil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 8 sec
Reputation Power: 0
awk program - Skip first & last record

Hi All,

I am parsing a pipe separated input file (PSV) with Pipe as a pattern. I need to skip the first & last record from the file while parsing.

Please note that, newline ('\n') is the record separator.

Please let me know how do I skip first & last records (they are header & footer records).

Thanks,
BSP

Reply With Quote
  #2  
Old November 18th, 2005, 05:22 PM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,307 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 4 h 28 m 57 sec
Reputation Power: 48
you did not give us a clue about how to identify these records, so this is as good as it gets:
Code:
awk -V var=`cat filename | wc -l` ' NR > 1 && NR < var ' filename

Reply With Quote
  #3  
Old November 19th, 2005, 05:12 AM
iribach iribach is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 23 iribach User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 31 m 47 sec
Reputation Power: 0
why not a little logic

Code:
   init a savedline to NULL
   while read line{
      print the saved line if not NULL # skip THE FIRST LINE
      save the line to savedline
   }
   # skip THE LAST LINE
 


that's all

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > awk program - Skip first & last record


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway