Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Add leading zeros to columns in a file Post 302545421 by chumsky on Monday 8th of August 2011 09:48:56 AM
Old 08-08-2011
Add leading zeros to columns in a file

Hello Gurus,

Quick question. I have a file with the following records:

A~000000000000518000~SLP ~99991231~20090701~88.50~USD~CS~
A~000000000000518000~SLP ~99991231~20090701~102.00~USD~CS~
A~000000000000772000~SLP ~99991231~20100701~118.08~USD~CS~

I wold like to do the following:
1. Add leading zeros before column 6, such that there are 5 places, and 2 decimal positions
2. Add a space after the value of column 7 and another space after the value of column 8, such that the output file looks like the following:

A~000000000000518000~SLP ~99991231~20090701~00088.50~USD ~CS ~
A~000000000000518000~SLP ~99991231~20090701~00102.00~USD ~CS ~
A~000000000000772000~SLP ~99991231~20100701~00118.08~USD ~CS ~

Thanks in advance for your help!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Leading zeros

How to insert leading zeros into a left-justisfied zip code? e.g. Zip code is written as 60320 which is left-justified to make it be read as 0060320. We have to move it to right-justifiable then insert 2 leading zeros into it... ;) (1 Reply)
Discussion started by: wtofu
1 Replies

2. Shell Programming and Scripting

how to retain leading zeros

Hi All, I am working with a fixed width file Forrmat. C1 Number (10,3) C2 Number (10,3) e.g. c1= 0000000100.000 c2= 0000000020.000 0000000100.0000000000020.000 I have to perform c1 - c2 . i.e. I want answer to be 0000000080.000. but I am loosing the leading zeros( only getting... (3 Replies)
Discussion started by: Manish Jha
3 Replies

3. Shell Programming and Scripting

truncating leading zeros of a column in a file

Hi I have a file in which I have 5 columns which are delimited by “|” as shown ABC|12|YAK|METRIC|000000019.5 XYZ|10|ABX|META|000000002.5 Now my requirement is to take the last column trim the leading zero's for that column values and write back to the same file in the same... (7 Replies)
Discussion started by: nvuradi
7 Replies

4. Shell Programming and Scripting

Help with adding leading zeros to a filename

Hi i need help in adding leading zero to filenames e.g file name in my folder are 1_234sd.txt 23_234sd.txt the output i need is 001_234sd.txt 023_234sd.txt can i do this shell scripting please help (2 Replies)
Discussion started by: rsmpk
2 Replies

5. Shell Programming and Scripting

Add leading zeros in floating point variable

I need to add leading zeros in a floating point numbers. The length of the number should be 13 including decimal. The input number is changing so number of leading zeros is not fix. For example input output 216.000 000000216.000 1345.000 000001345.000 22345.500 ... (4 Replies)
Discussion started by: reeta_shri
4 Replies

6. Shell Programming and Scripting

Numbers with leading zeros

Hi, i have a variable which conatins values like 00001,0003,00067,00459. I want to use the values one by one and in the same form as they are like 00001,0003,00067,00459. Also can anyone tell me how to increment those numbers by 1,keeping the format as same like 00002,0004,00068,00460.... (5 Replies)
Discussion started by: arijitsaha
5 Replies

7. Shell Programming and Scripting

Help deleting leading zeros in a file

I have a list of numbers extracted and need to delete the leading zeros from them, but when i do so, the command I am using also deletes numbers that end in Zero as well. eg 10, 20, 30, etc this is part of a larger script and the only way I can think of is to try and detect the 10,20 30 etc in... (19 Replies)
Discussion started by: kcpoole
19 Replies

8. 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

9. Shell Programming and Scripting

Adding Leading Zeros for date in a file

Hello, I have a pipe separated file with two major lines. One is header and another is detail line. Header starts with H and Detail start with D. Sample Content: H|123456|Joes Watson|UK|4/5/2016|12/5/2016|3456|HC|NW|||||| D|123456|Joes... (13 Replies)
Discussion started by: Mannu2525
13 Replies

10. 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
slpd(1M)																  slpd(1M)

NAME
slpd - Service Location Protocol (SLP) Daemon SYNOPSIS
configuration_file] registration_file] log_file] pid_file] DESCRIPTION
The daemon provides the functionality of the Directory Agent and Service Agent for the Service Location Protocol ("SLP") version 2. SLP provides a scalable framework that allows the networking applications to discover the existence, location and configuration of networked services in the enterprise networks. provides the functionality of the following services: This agent collects service advertisements from the service agents or applications providing the services and caches them in its memory. The DA then provides this services information to the clients (user agents) trying to discover the service information. Directory agents advertise their presence through directory agent advertisements. This server registers the service information of all the services that are advertised by the corresponding service agents to this server. It then answers the queries from the user agents about the information on the services that were registered with this server by the ser- vices agents. It also forwards the registrations to any Directory Agents that may be present in its scope. also provides a option whereby the existing services which are not slp enabled can advertise information by storing this information in a static registration file. See below for the options. reads this file and provides the information to the user agents. can be either started as an SA server or DA by setting to either false or true in the configuration file. In both the cases, runs as a daemon listening for SLP requests. When is acting as a DA, it registers the services coming from within the host acting as a SA server and acts as DA for the User Agents (UAs) running on the remote machines. can be configured to provision services within a scope that is configured by the administrator by setting in the configuration file. SLP daemon will answer to requests only if it falls within this scope. This feature of scoping of SLP daemon provides provisioning of services in an Enterprise network based on administration needs, geographical needs or department needs and also provides scalability. See RFC2608 for more information on the Service Location Protocol. Without any arguments, reads the default configuration file, Options The options are: Specifies the configuration file to The default configuration file is Do not detach from the terminal. Specifies the log file that receives log messages. The default log file is Specifies the file that holds the process id. The default process id file is Specifies the registration file to for reading service information. The default registration file is To restart the daemon, send it a signal. To kill the daemon, send it a signal. The command can also be used for sending signals to the server process (see the slpdc(1M) manpage). DIAGNOSTICS
Any errors encountered by in the registration or configuration file or in normal operation are logged in the log file, which is the default file. To change this log file, use the command. AUTHOR
was developed by the Caldera Systems, Inc. FILES
SLP configuration file SLP registration file File storing process ID Default SLP log file SEE ALSO
kill(1), slpdc(1M), signal(2), libslp(3N), slp.conf(4), slp.reg(4). RFC 2165, RFC 2608, RFC 2609, RFC 2614. slpd(1M)
All times are GMT -4. The time now is 04:11 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy