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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
To cut entire column from a file and apend it to another file as another column sakthifire Shell Programming and Scripting 4 06-25-2008 01:27 AM
How to check Null values in a file column by column if columns are Not NULLs Mandab Shell Programming and Scripting 7 03-15-2008 06:57 AM
delete blank lines from a file sachin.gangadha UNIX for Dummies Questions & Answers 2 12-04-2007 04:13 PM
Adding blank white sapce at specific column Jae Shell Programming and Scripting 6 08-08-2007 05:20 AM
Blank Lines - End of file saabir Shell Programming and Scripting 4 07-15-2003 08:55 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-28-2007
Registered User
 

Join Date: Dec 2007
Posts: 16
Blank column in a file.

hi,
Please tell me a way in which i can find out all the blank columns in the file which is pipe-delimited.after finding the blank column i want to find the line number.
Reply With Quote
Forum Sponsor
  #2  
Old 12-28-2007
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
For ex:
Code:
> cat f3
231|212|212
231|212|212
|212|212
231|212|212
231|||212
231|212|212
231|212|
Code:
>awk '{
     for(i=0;i<=NF;i++)
        if ( $i == "" )
           print "line:"NR " column:"i
}' FS="|" f3
line:3 column:1
line:5 column:2
line:5 column:3
line:7 column:3
Reply With Quote
  #3  
Old 12-28-2007
Registered User
 

Join Date: Dec 2007
Posts: 16
Thanks a lot sir.
It worked.
Reply With Quote
  #4  
Old 12-28-2007
Registered User
 

Join Date: Dec 2007
Posts: 16
D 2382994 ACE 9724029474 9728690617 000 Dallas County Utility 0 ADSL STATIC 6000 N O'Connor Blvd
D 2685592 ACE 8584511009 8584518859 544 JAMES KENNEDY 12 ADSL STATIC 14755 Bud'S Ln
-

but as the last column is empty it is not finding this line.
Can u please tell me?
Reply With Quote
  #5  
Old 12-28-2007
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
hi, where are the pipes?
Reply With Quote
  #6  
Old 12-28-2007
Registered User
 

Join Date: Dec 2007
Posts: 16
Sorry.
last one is having - sign and all the other fields r blank.
so i should get the column no,. and line no.
D|2382994 ACE|9724029474|9728690617 000|Dallas County Utility|0|ADSL STATIC|6000|N O'Connor Blvd
D|2685592 ACE|8584511009|8584518859 544|JAMES KENNEDY|12|ADSL STATIC|14755|Bud'S Ln
-
Reply With Quote
  #7  
Old 12-28-2007
Klashxx's Avatar
HP-UX/Linux/Oracle
 

Join Date: Feb 2006
Location: Almerķa, Spain
Posts: 383
The third register has only one field and it is not empty, anyway if you want to fix the code to match it:

Code:
>awk '{
     for(i=0;i<=NF;i++)
        if ( $i == "" || $i == "-" )
           print "line:"NR " column:"i
}' FS="|" f3
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0