remove precursing zeros


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting remove precursing zeros
# 1  
Old 08-10-2005
Computer remove precursing zeros

Hello all, I have a list of reports for stores that are numbered like:
s001845,s000022,s198490,s020048,s002385

however the users are displaying the reports as:
1845,22,198490,20048,2385

It isn't real critical but I would like to associate them so they are the same. And since the users are used to viewing the seconed set of data, Is there a way to remove the 's' and precursing zeros? I was thinking of a tr command, but quickly realized the folly in that idea. I am not sure that a sed would work. Like I say it's not to big of a deal so if there is something simple I am all for it. Thanks in advance for any replies guys, I appriciate it.
# 2  
Old 08-10-2005
Code:
print "s001845,s000022,s198490,s020048,s002385" | nawk 'gsub(/s[0]*/,"",$0) 1'

Code:
1845,22,198490,20048,2385

or
Code:
print "s001845,s000022,s198490,s020048,s002385" | sed -e 's/s[0]*//g'

Code:
1845,22,198490,20048,2385


Last edited by tmarikle; 08-10-2005 at 07:29 PM..
# 3  
Old 08-10-2005
Smokin' that will work brilliantly. Thanks so much tmarikle, and for the quick response. You rock!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Remove first 3 leadings zeros and replace with space

Hi Folks - I need help manipulating a file. For column 2, I need to replace the first 3 leading zeros with spaces. The file looks like such: 00098|00011250000003|00000000000.0200|D|1|07|51|04INDP |04|00820|CS|000000|092717|000000000000.0000|000|... (3 Replies)
Discussion started by: SIMMS7400
3 Replies

2. UNIX for Beginners Questions & Answers

Remove trailing zeros from numbers

Hi, I am trying to remove trailing zeros from numbers in a csv file. CSV Input : 0.5000,abc,2.00,2.400,285.850,285a.850,205.180800,mno000,a0b0,2.860 Expected Output : .5,abc,2,2.4,285.85,285a.850,205.1808,mno000,a0b0,2.86 Can you please help. Thanks. (11 Replies)
Discussion started by: manubatham20
11 Replies

3. Shell Programming and Scripting

Remove leading zeros separated by pipe

I have a below file and I wanted to remove the leading zeros in each field separated by pipe File: 01/09/2017|2017/09/06|2017/02/06|02/06/2017|02/06/2017 06:50:06 AM|2017/02/06|02/06/2017|02/07/2017 05:45:06 AM| 02/08/2017|2017/08/06|2017/09/06|02/05/2017|02/07/2017 05:40:06... (4 Replies)
Discussion started by: Joselouis
4 Replies

4. Shell Programming and Scripting

Ho to remove leading zeros from a csv file which is sent from a UNIX script

Hi All, I am using a informatica job to create a csv file and a unix script the mail the generated file.Everything is working fine but I am not seeing leading zeros in the csv file sent in the mail.These zeros were present when the .csv file was generated by informatica procees. Is there any... (11 Replies)
Discussion started by: karthik adiga
11 Replies

5. UNIX for Dummies Questions & Answers

Remove zeros from first field, but print all fields

Hello Everyone, I've got a comma-delimited file that looks like this: 0012,123 ,456 ,05/12/2014 0123,525 ,286 ,05/12/2014 0456,791 ,300 ,05/12/2014 1095,759 ,300 ,05/12/2014 1344,576 ,292 ,05/12/2014 1558,551 ,283 ,05/12/2014 002183719, , ... (9 Replies)
Discussion started by: Scottie1954
9 Replies

6. Shell Programming and Scripting

Remove trailing zeros

Hi I have a simple request but can't find the answer. I want to remove trailing zeros, and in some cases the fullstops, from the input data. Example of input file: FR002_15.000_20.000 SD475_5.000_10.500 FG5647_12.250_15.500 BH2463_30.555_32.000 Desired output file would be: ... (10 Replies)
Discussion started by: theflamingmoe
10 Replies

7. Shell Programming and Scripting

awk to remove leading zeros for a hex number

Is it possible by using awk to remove leading zeros for a hex number? ex: 0000000011179E0A -> 11179E0A Thank you! (4 Replies)
Discussion started by: carloszhang
4 Replies

8. UNIX for Advanced & Expert Users

trimming zeros

Hi, I want to trim +with leading zero's with amount fields.I know using awk for trimming leading zeros with +,but I want get the entire row itself. cat file_name |awk -F " " '{printf "%14.4f%f\n",$4}' ex: 10 xyz bc +00000234.4500 20 yzx foxic +002456.000 Expexted 10 xyz bc... (3 Replies)
Discussion started by: mohan705
3 Replies

9. UNIX for Dummies Questions & Answers

pad Zeros

Hi can I know command to pad Zeros to a value I get 16 and I need to send 0000000016 (5 Replies)
Discussion started by: mgirinath
5 Replies

10. Shell Programming and Scripting

Remove O and preceeding zeros in a string

Hi all, Can anybody help me out to write a program in perl to remove O and preceeding zeros. for eg input is O0000123089 - output 123089 Thanks Mahalakshmi.A (10 Replies)
Discussion started by: mahalakshmi
10 Replies
Login or Register to Ask a Question