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
Awk scrip to remove empty field bombcan Shell Programming and Scripting 4 06-11-2008 01:57 PM
Print last occurrence if first field match Raynon Shell Programming and Scripting 9 03-13-2008 03:28 AM
Shell Script using Join, empty field help! tibbyuk UNIX for Dummies Questions & Answers 1 02-25-2008 12:33 PM
regexp to print after a field seperator ramky79 Shell Programming and Scripting 7 05-09-2007 07:31 PM
egrep field print knc9233 UNIX for Dummies Questions & Answers 2 02-14-2007 02:07 PM

 
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 Rating: Thread Rating: 3 votes, 4.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-14-2008
yahyaaa's Avatar
yahyaaa yahyaaa is offline
Registered User
  
 

Join Date: May 2008
Location: Jordan
Posts: 89
How to print empty line when the a field is changed

Hi all,

I have this input file ..

BSS01 107 Swafieh 11/06/2008 12:06:57
BSS01 111 Ramada_Hotel 12/06/2008 11:37:20
BSS01 147 Kalha_Rep 11/06/2008 19:13:39
BSS01 147 Kalha_Rep 11/06/2008 19:13:39
BSS06 601 Abu_Alanda_Caragat 12/06/2008 02:57:11
BSS06 601 Abu_Alanda_Caragat 12/06/2008 11:10:37
BSS06 601 Abu_Alanda_Caragat 12/06/2008 11:10:37
BSS06 601 Abu_Alanda_Caragat 12/06/2008 11:10:37
BSS06 601 Abu_Alanda_Caragat 12/06/2008 11:10:37
BSS08 802 Jada_SDH 12/06/2008 09:53:59
BSS08 805 Rakeen_Batter 12/06/2008 09:53:58
BSS08 805 Rakeen_Batter 12/06/2008 09:53:58
BSS08 805 Rakeen_Batter 12/06/2008 09:53:58
BSS08 811 Sarfa 12/06/2008 09:53:57
BSS08 821 Qaser_SDH 12/06/2008 09:54:00
BSS08 821 Qaser_SDH 12/06/2008 09:54:00
BSS08 821 Qaser_SDH 12/06/2008 09:54:00

I need to print empty line when the second field is changed.
like this

BSS01 107 Swafieh 11/06/2008 12:06:57

BSS01 111 Ramada_Hotel 12/06/2008 11:37:20

BSS01 147 Kalha_Rep 11/06/2008 19:13:39
BSS01 147 Kalha_Rep 11/06/2008 19:13:39

BSS06 601 Abu_Alanda_Caragat 12/06/2008 02:57:11
BSS06 601 Abu_Alanda_Caragat 12/06/2008 11:10:37
BSS06 601 Abu_Alanda_Caragat 12/06/2008 11:10:37
BSS06 601 Abu_Alanda_Caragat 12/06/2008 11:10:37
BSS06 601 Abu_Alanda_Caragat 12/06/2008 11:10:37

BSS08 802 Jada_SDH 12/06/2008 09:53:59

BSS08 805 Rakeen_Batter 12/06/2008 09:53:58
BSS08 805 Rakeen_Batter 12/06/2008 09:53:58
BSS08 805 Rakeen_Batter 12/06/2008 09:53:58

BSS08 811 Sarfa 12/06/2008 09:53:57

BSS08 821 Qaser_SDH 12/06/2008 09:54:00
BSS08 821 Qaser_SDH 12/06/2008 09:54:00
BSS08 821 Qaser_SDH 12/06/2008 09:54:00

I tried this awk but still doesnt work ..
any help is appreciated ..

BEGIN { site = $2 }

/BSS/{ if ( $2 == site )

printf "%s\n",$0; site = $2

else

printf "\n" ; site = $2
}

Thanks
 

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 07:09 AM.


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