|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Web Site Management > Scripts > awk program - Skip first & last record |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|