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
Extract some common fields from 1 file that are presnt in another file unxusr123 UNIX for Dummies Questions & Answers 1 06-11-2008 03:33 AM
How to search for two fields jisha Shell Programming and Scripting 3 04-23-2008 06:16 AM
search and replace different fields tungaw2004 UNIX for Dummies Questions & Answers 3 03-29-2007 04:16 AM
help me to count no of fields in a file babu@shell Shell Programming and Scripting 7 10-31-2006 01:36 AM
How to add fields in a file bjorb Shell Programming and Scripting 2 10-13-2005 09:11 AM

Closed Thread
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
  #1 (permalink)  
Old 10-20-2008
Pablo_beezo Pablo_beezo is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 85
search fields within a file

I need to be able to search multiple fields within a file that contain blank (nothing).

Not sure what command to use? thought it would be grep but not sure how to write it

The reason is i have a script that when it does this and identifies a field which has a blank it errors out of the script and stops running.

Any help would be appreciated
  #2 (permalink)  
Old 10-20-2008
jim mcnamara jim mcnamara is online now Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,784
Define the "blank fields" how long are they, where are they located - what offset from the stat of the record?
  #3 (permalink)  
Old 10-20-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink include a brief section of you input file

and also what you are trying to search on.

That will make it easier to help with a solution.
  #4 (permalink)  
Old 10-20-2008
Pablo_beezo Pablo_beezo is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 85
I have 8 fields to search on within a 20 field file. The sizes of them vary from 3 - 50 bytes

The file i am reading in is a csv file see sample entrant below:

"hello","xxxx1","Mr","J","","Smith","","","17 Somewhere Drive","nowhere","","","","sometown","pp1 ppi","08AM30","","","",""
  #5 (permalink)  
Old 10-20-2008
danmero danmero is offline Forum Advisor  
  
 

Join Date: Nov 2007
Location: 45.48-73.63
Posts: 1,434
You can start from here:
Code:
awk -F"," '{for(i=1;i<=NF;i++)if($i=="\"\""){printf "%s %s %s %s %s %s %s\n","File:",FILENAME,",line:",NR,",column:",i,"is empty"}}' file
Closed Thread

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:54 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