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
iterate through records using AWK harris2107 Shell Programming and Scripting 6 08-21-2007 07:07 PM
Count No of Records in File without counting Header and Trailer Records guiguy Shell Programming and Scripting 2 06-07-2007 09:15 AM
Records charbel Shell Programming and Scripting 3 06-29-2006 06:16 AM
temperature records uzerx HP-UX 0 06-06-2006 10:47 AM
A records Deuce UNIX for Dummies Questions & Answers 3 09-25-2001 08:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-18-2007
Registered User
 

Join Date: Sep 2006
Posts: 209
Stumble this Post!
how to put nil at the end of each records.

Hello,

I have a file with 100,000 records. Each record have many fileds and used "," to split (like below):

0100,apple,john,2233,N,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,IDN,
0201,steve,2435,N,0,49,6.658,0,6.658,37.104302,0,0,0,0,0,37.104302,0,49,6.658,0,6.658,37.104302,UAE, AED
222,cu1,marry,2436,N,0,3,0.416,0,0.416,2.318322,0,0,0,0,0,2.318322,0,3,0.416,0,0.416,2.318322,UAE,AE D

however, some of them at the end is empty. Can i put the NIL?

Itried to use "sed -e "s/,,/,NIL,/g" a.txt > b.txt", but it's not work.

expected output:
0100,apple,john,2233,N,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,IDN,NIL
0201,steve,2435,N,0,49,6.658,0,6.658,37.104302,0,0,0,0,0,37.104302,0,49,6.658,0,6.658,37.104302,UAE, AED
222,cu1,marry,2436,N,0,3,0.416,0,0.416,2.318322,0,0,0,0,0,2.318322,0,3,0.416,0,0.416,2.318322,UAE,AE D

or check the front information and put the same?

0100,apple,john,2233,N,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,IDN,
0100,orange,et,2233,N,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,IDN,ACC
0201,steve,2435,N,0,49,6.658,0,6.658,37.104302,0,0,0,0,0,37.104302,0,49,6.658,0,6.658,37.104302,UAE, AED
222,cu1,marry,2436,N,0,3,0.416,0,0.416,2.318322,0,0,0,0,0,2.318322,0,3,0.416,0,0.416,2.318322,UAE,

OUTPUT:
0100,apple,john,2233,N,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,IDN,ACC
0100,orange,et,2233,N,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,IDN,ACC
0201,steve,2435,N,0,49,6.658,0,6.658,37.104302,0,0,0,0,0,37.104302,0,49,6.658,0,6.658,37.104302,UAE, AED
222,cu1,marry,2436,N,0,3,0.416,0,0.416,2.318322,0,0,0,0,0,2.318322,0,3,0.416,0,0.416,2.318322,UAE,AE D
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-18-2007
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,002
Stumble this Post!
Code:
echo '0100,apple,john,2233,N,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,IDN,' | sed 's/,$/&NIL/'
Reply With Quote
  #3 (permalink)  
Old 07-19-2007
Registered User
 

Join Date: Sep 2006
Posts: 209
Stumble this Post!
it's not work
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:28 PM.


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

Content Relevant URLs by vBSEO 3.2.0