The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
column 1 line transitions part two! ajp7701 Shell Programming and Scripting 7 04-18-2008 06:16 PM
how to read the column and print the values under that column gemini106 Shell Programming and Scripting 6 03-28-2008 07:05 AM
print a line containing word in a column using grep useless79 Shell Programming and Scripting 2 11-23-2007 04:32 AM
to print column using awk cdfd123 Shell Programming and Scripting 2 07-26-2007 02:15 PM
Print the line containing the maximum value in a column kingkong UNIX for Advanced & Expert Users 22 02-03-2006 10:38 AM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 04-17-2008
ajp7701 ajp7701 is offline VIP Member  
Supporter
  
 

Join Date: Dec 2007
Posts: 63
print line before column 1 transitions

I have a space delimited text file with thousands of lines, COLA.TXT that looks for example like this:
AA 123 456 789
AA 987 987 987
AA 987 988 888
AA 999 999 999
B 123 456 789
B 111 111 111
CCD 123 456 789
CCD 321 654 987
CCD
EE 11 11
EE
EE
EE 00 00 00
EE



Anyway, I need a script that will print the first and last line of each transition of the first column. In other words it will print the first and last lines of each "section". Sample output might look something like this:
AA 123 456 789
AA 999 999 999
B 123 456 789
B 111 111 111
CCD 123 456 789
CCD
EE 11 11
EE


Note when there are only two lines in a section (B) it still prints the first and second lines. there are always at least 2 lines. sometimes there are 10+ lines though. I see this as being pretty complicated? I dont know though, everybody on here is amazing!!! Thank you so much in advance!
 

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 08:45 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