Padding zeros after removing commas in file


 
Thread Tools Search this Thread
Operating Systems HP-UX Padding zeros after removing commas in file
# 1  
Old 11-09-2005
Padding zeros after removing commas in file

Hi Gurus,

There is a ASCII file in which a comma is used as a seperator for the amount field when the amount exceed seven digits: e.g. 0001300,000. Now, this comma needs to be removed from this field, after padding leading zeros (to maintain the ASCII positions) e.g. 00001300000. Could anyone post a detailed solution which can handle this requirement?. There are multiple records in the file which fall under this category.


Thanks for your help

Prakash
# 2  
Old 11-09-2005
This is gnu sed....
Code:
$ echo "0001300,000" | sed -r 's/([0-9]{7}),([0-9]{3})/0\1\2/'
00001300000

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Removing commas from CSV file

Hi I'm creating a sh script to generate a csv file. The CSV contains the values from a sql table. The content looks this: a,b,c,c2,c3,,,,,,,,,,,d,e I have some code that can separate the fields using the comma as delimiter, but some values actually contain commas, such as... (2 Replies)
Discussion started by: preema
2 Replies

2. Shell Programming and Scripting

Fixed with file- removing leading zeros and adding the space

Hi All, i have a fixed width file , where each line is 3200 length. File: 1ABC 1111 2222 3333 000012341 1001 2ABC 1111 2222 3333 000012342 1002 3ABC 1111 2222 3333 000112343 1003 1DEF 5555 4444 9696 000012344 1004 2DEF 5555 2323 8686 000012345 1005 3DEF 5555 1212 7676 000012346 1006 ... (1 Reply)
Discussion started by: mechvijays
1 Replies

3. Shell Programming and Scripting

Removing commas within semicolon in a flat file

i am recieving a flat file ( comma seperated ) with comma in between double quotes in any of the source fields . i need to remove the comma in double quotes and process the file thereafter fields in file ========= col1,col2,col3,col4 input can be any of the followng... (31 Replies)
Discussion started by: r_t_1601
31 Replies

4. Shell Programming and Scripting

Removing commas within semicolon in a flat file

Hi , Im relatively new to unix and have to process a comma serparated flat file . I recieve some of the fields in double quotes and i want to remove it .. INPUT ==== filed1,field2,field3,"fie,ld4" OUTPUT ===== field1,field2,field3,"field4" can anyone tell me how to achieve... (10 Replies)
Discussion started by: r_t_1601
10 Replies

5. Shell Programming and Scripting

Padding with zeros.

Hi Friends, I would like to left pad with "0's" on first column say (width six) I have a large file with the format: FILE: 1: ALFRED 84378 NY 8385: JAMES 88385 FL 323: SMITH 00850 TX My output needs to be like: 000001: ALFRED 84378 NY 008385: JAMES 88385 FL 000323: SMITH... (10 Replies)
Discussion started by: sbasetty
10 Replies

6. Shell Programming and Scripting

Need help in removing commas

i have the below line as output from a script. I want to delete the string "," and get the output without comma, cat D* | grep "bytes free" | awk '{print $3}' | ????? output: 40,966,189,056 Desired O/P: 40966189056 (1 Reply)
Discussion started by: ali560045
1 Replies

7. Shell Programming and Scripting

bash typeset padding with zeros

Hi everybody, I have a question about typesetting. I originally wrote a script for use with ksh and now I am on a system that I cannot modify, and it only has bash. In the original script I just did typeset -RZ4 variable and it would add the leading zeros. In bash, it doesn't work. I've... (2 Replies)
Discussion started by: jwheeler
2 Replies

8. Shell Programming and Scripting

Help needed in padding leading zeros

Hi all, I have file with numeric values. I need to pad each value with leading zeros such that total lenght of each value is 16. Example: cat tmp.txt 502455 50255 5026 5027 5028 Output 0000000000502455 0000000000050255 0000000000005026 0000000000005027 0000000000005028 Any... (12 Replies)
Discussion started by: jakSun8
12 Replies

9. Shell Programming and Scripting

Removing leading zeros from a variable

How do I remove or add leading zeroa from a variable. To make variable 10 characters long when adding zeros. (6 Replies)
Discussion started by: toshidas2000
6 Replies

10. UNIX for Dummies Questions & Answers

removing commas from text file

Dear all I have a file which looks like this xxxxxxxxxxxxxx,xxx,xxxxxxxxxx xxxxxxxxxxxxxx,xxx,xxxxxxxxxx etc basically 14 characters then a comma, three characters, then a comma then 10 characters. We are uploading this file to our mainframe and they want the commas removed, so it... (6 Replies)
Discussion started by: hcclnoodles
6 Replies
Login or Register to Ask a Question