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
need for loop to include fields as one line prkfriryce Shell Programming and Scripting 8 03-23-2007 09:49 AM
fill a NIL into the blank field happyv Shell Programming and Scripting 8 03-23-2007 01:49 AM
field separator as regexp Abhishek Ghose Shell Programming and Scripting 2 02-15-2006 05:49 PM
awk: How to check if field is blank? yongho Shell Programming and Scripting 7 06-09-2005 08:35 AM
How do I specify tab as field separator for sort? SSteve UNIX for Dummies Questions & Answers 8 04-26-2005 01:39 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 07-12-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
vgersh99


The o/p wants to detect the absence of field2 and field3.

vino
Reply With Quote
Forum Sponsor
  #9  
Old 07-12-2005
ReV ReV is offline
Registered User
 

Join Date: Jun 2005
Posts: 34
empty fields are also spaces. but i need them to be shown as a blank in the output.
Reply With Quote
  #10  
Old 07-12-2005
ReV ReV is offline
Registered User
 

Join Date: Jun 2005
Posts: 34
Quote:
Originally Posted by vino
vgersh99


The o/p wants to detect the absence of field2 and field3.

vino
yes, exactly. the absence of field2 and 3 are not detected. thanks vino for explaining it
Reply With Quote
  #11  
Old 07-12-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
If field2 and field3 always follow a same pattern, then look for its absence, and introduce a ;

Vino
Reply With Quote
  #12  
Old 07-12-2005
ReV ReV is offline
Registered User
 

Join Date: Jun 2005
Posts: 34
Quote:
Originally Posted by vino
If field2 and field3 always follow a same pattern, then look for its absence, and introduce a ;

Vino
there are no patterns, because all the fields are numbers. they can either be blank or numbers.

however, the number of fields in each line is the same. i am not sure if this will be a helpful pt to make use of
Reply With Quote
  #13  
Old 07-12-2005
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Add this as well to the original solution.

Code:
sed -e 's/^\([0-9][0-9]*\);\([0-9][0-9]*\)$/\1;;;;\2/g'
A very crude one tho'.

Vino
Reply With Quote
  #14  
Old 07-12-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
A hint: Looks like each field starts and ends in well defined columns with a variable number of trailing spaces to fill the field. You're going to need to exploit that property for a correct solution. We need the starting column numbers. With a modern sed, it is an easy two step process. Deposit a separator after, say, columns 10, 15, 20, 40. Then remove spaces before the separator.
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 04:58 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