The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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

Join Date: Sep 2006
Posts: 209
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
  #2 (permalink)  
Old 07-19-2007
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,119
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/'
  #3 (permalink)  
Old 07-19-2007
happyv happyv is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 209
it's not work
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 08:42 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