The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
combining fields in two text fields shocker Shell Programming and Scripting 3 01-16-2008 07:27 AM
amount of memory in my server new2ss UNIX for Dummies Questions & Answers 2 11-06-2006 06:28 AM
sed X amount of times - X is dynamic Loriel Shell Programming and Scripting 2 02-17-2005 04:38 PM
Amount of RAM (Memory) samudimu UNIX for Dummies Questions & Answers 4 07-29-2003 10:40 AM
How to get amount of memory installed. elgholm UNIX for Dummies Questions & Answers 4 08-24-2001 04:04 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-05-2008
Registered User
 

Join Date: Feb 2007
Posts: 109
Stumble this Post!
Trimmng leading 0's from amount fields

Hi


I need to remove leading zeros if that filed is amount filed and trimmimg leading and trailing spaces


U | U|1999-01-01|000004384|000002192|0000000000000000.0000|0000000000000000.0000| U|XXX|0000000000000685.5800| FIXED |U



Tried with this command ,I am not getting expected o/p

sed -e 's/ *|/|/g' -e 's/[ ]*^//g' -e 's/|00*\/|0\./g' file

o/p

U|U|1999-01-01|000004384|000002192|0.0000|0.0000|U|XXX|685.5800|FIXED|U


Thanks in advance
Mohan
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-05-2008
Registered User
 

Join Date: Apr 2008
Location: Bangalore
Posts: 120
Stumble this Post!
Hi,

echo "U | U|1999-01-01 |000004384|000002192|0000000000000000.0000|0000000000000000.0000| U|XXX|0000000000000685.5800| FIXED |U" | sed -e 's/| */|/g' -e 's/ *|/|/g' -e 's/|00*/|/g' -e 's/|\./|0\./g'

Output:

U|U|1999-01-01|4384|2192|0.0000|0.0000|U|XXX|685.5800|FIXED|U

Thanks
Penchal
Reply With Quote
  #3 (permalink)  
Old 05-06-2008
Registered User
 

Join Date: Feb 2007
Posts: 109
Stumble this Post!
Hi

Thanks


MR
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:54 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