Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Replace colon with blank space Post 302576193 by chumsky on Thursday 24th of November 2011 02:29:47 AM
Old 11-24-2011
Replace colon with blank space

Dear Gurus,

I have a unix file with multiple colons on each row, and I would like to replace each colon with a blank space using the awk command.

For example, I have the following data:

Data:
---------
Code:
A~000000000000518000~SLP:~99991231~20090701~00102.00~USD:~CS:~
A~000000000000772000~SLP:~99991231~20090701~00118.08~USD:~CS:~
A~000000000000775000~SLP:~99991231~20090701~00118.08~USD:~CS:~
A~000000000001720007~SLP:~99991231~20101101~00194.40~USD:~CS:~

---------

And result I would like to achieve is as follows:

Result:
---------
Code:
A~000000000000518000~SLP ~99991231~20090701~00102.00~USD ~CS ~
A~000000000000772000~SLP ~99991231~20090701~00118.08~USD ~CS ~
A~000000000000775000~SLP ~99991231~20090701~00118.08~USD ~CS ~
A~000000000001720007~SLP ~99991231~20101101~00194.40~USD ~CS ~

---------

Thanks in advance!

Chumsky


Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 11-24-2011 at 03:40 AM.. Reason: Please use code tags for code and data samples, thank you
 

10 More Discussions You Might Find Interesting

1. AIX

How can i replace a character with blank space?

i want a command for my script!!! say file consists of character 123 125 127. i need a query to replace the number 2 with 0 so the output should be 103 105 107. i use unix-aix (8 Replies)
Discussion started by: rollthecoin
8 Replies

2. UNIX for Dummies Questions & Answers

Multiple field separators in awk? (First a space, then a colon)

How do I deal with extracting a portion of a record when multiple field separators are involved. Let's say I have: Mike Harrington;(555) 555-5555:250:100:175 Christian Dobbins;(555) 555-2358:155:90:201 Susan Dalsass;(555) 555-6279:250:60:50 Archie McNichol;(555) 555-1348:250:100:175 Jody... (3 Replies)
Discussion started by: doubleminus
3 Replies

3. Shell Programming and Scripting

Replace a blank space with string "\\ "

Hi, I have a requirement to replace a every blank space with char "\\ ". Like string "God Love" to "God\\ Love" and "God Love" as "God\\ \\ Love". and only in the sed. We have already a script but it is replaceing all continuous blank space with one "\\ ". which is as DIR=`sudo echo... (7 Replies)
Discussion started by: Akshay4u
7 Replies

4. Shell Programming and Scripting

loop to replace txt and add command inside of colon (:)

in one of my script..I have some thing like john:christina : one:: and i want to make it like john:chritina:two:(date command):jackey: basically change 'one' to 'two' and run date :command and add other name: (30 Replies)
Discussion started by: Learnerabc
30 Replies

5. Shell Programming and Scripting

Replace comma with a blank space using SED

Hello everyone, I want to replace all "," (commas) with a blank space My command thus far is: cat test.text | sed -e s/\`//g | awk '{print$1" "$2" "$3}' I'm sure you guys know this, but the SED command that I am using is to get rid of the "`" (tics). which gives me: name ... (5 Replies)
Discussion started by: jayT
5 Replies

6. Shell Programming and Scripting

Cut last blank space

Hello, I am using this to get only directories : ls -l | grep '^d'and here is the result : drwx------ 13 so_nic sonic 13 Nov 4 13:03 GLARY drwx------ 3 so_nic sonic 3 May 6 2010 PSY2R drwx------ 15 so_nic sonic 15 Oct 14 08:47 PSYR1 But I only need to keep this... (7 Replies)
Discussion started by: Aswex
7 Replies

7. Shell Programming and Scripting

Replace carriage return with colon on specific column

Hi, I have to process four source text files with possibility to contain carriage return on the particular column. Thus, i need to replace the carriage return with 3 colons <:::> The particular column position in the source files is not fix but the name is fixed. That is, say for example,... (4 Replies)
Discussion started by: agathaeleanor
4 Replies

8. UNIX for Dummies Questions & Answers

blank space

hi everyone, i have a problem in unix script , i need to remove line that has blank , not blank line . example: mahm,,jdggkhsd,ghskj,,fshjkl can anyone help? (4 Replies)
Discussion started by: Reham.Donia
4 Replies

9. Shell Programming and Scripting

Not delete space blank

Hi everyone, i need to "grep" a file with a string with space blanks, like this: grep "XXXX XX" file.txt The problem, i need put the "XXXX XX" in a string variable. When the script executes the grep, do: gresp XXXX XX file.txt How can i solve this problem? The... (5 Replies)
Discussion started by: Xedrox
5 Replies

10. Shell Programming and Scripting

How to replace colon in HH:MI:SS to hypen?

I have a file that contains timestamp in some of the rows in the file and the field separator is colon and some of the rows have numerical values, timestamp and characters with colon as the field separator We are looking to change colon in HH:MI:SS for the timestamp to hyphen “-“ leaving the field... (1 Reply)
Discussion started by: cumeh1624
1 Replies
SLPError(3N)															      SLPError(3N)

NAME
SLPError - Service Location Protocol (SLP) error codes SYNOPSIS
DESCRIPTION
SLP APIs return error code when the call does not succeed. These SLP error codes are defined in The various SLP Error codes returned by the SLP APIs, their values and their explanations are as follows: Passed to callback functions when the API library has no more data for them and therefore no further calls will be made to the callback on the currently outstanding operation. The callback can then signal to the main body of the client code that no more data will be forthcoming on the operation. The main body of the client code will then break out of data collection loops. On the last call of a callback during both an asynchronous and synchronous calls, the error code parameter has value and the other parameters are all NULL. If no results are returned by an API operation, then only one call is made, with the error parameter set to Indicates that no error occurred during the operation. There is no DA or SA service advertisement or attribute information in the language requested. However, at least one DA or SA indicates that there might be information for that service in another language by returning the error code. The SLP message was rejected by a remote SLP agent. The API returns this error only when no information was retrieved, and at least one SA or DA indicated a protocol error. The data supplied through the API may be malformed or a may have been damaged in transit. The API may return this error if an attempt to register a service was rejected by all DAs because of a malformed URL or attributes. SLP does not return the error if at least one DA accepted the registration. The API returns this error if the SLP request packet did not specify one or more of the scopes that neither slpd running on local machine has been configured with through the net.slp.useScopes property in the configuration file nor is there slpd running on any other machines which support them. If the SLP framework supports authentication, this error arises when the UA or SA failed to send an authenticator for requests or registrations in a protected scope. If the SLP framework supports authentication, this error arises when a authentication on an SLP message failed. An update for a non-existing registration was issued or the update includes a service type or scope different than that in the initial registration or successive incremental reg- istrations. The SA attempted to refresh a registration more frequently than the minimum refresh interval. The SA should call the appropriate API function to obtain the mini- mum refresh interval to use. If an unimplemented feature is used, this error is returned. An outgoing request overflowed the maximum network MTU size. The request should be reduced in size or broken into pieces and tried again. This error is returned when no reply can be obtained in the time specified by the configured timeout interval for a unicast request. This error indicates that the network cannot initialize properly. This error will also be returned if an SA or DA agent (slpd) can not be contacted. See and in libslp(3N) for more infor- mation. Out of memory error. This error is returned when the parameter passed to the function is bad. A networking failure during normal operations causes this error to be returned. A basic failure of the API causes this error to be returned. This occurs when a system call or library fails. The operation could not recover. In the C API, callback functions are not permitted to recursively call into the API on the same either directly or indirectly. If an attempt is made to do so, this error is returned from the called API function. If the API supports a type checking of registrations against service type templates, this error occurs if the attributes in a registration do not match the service type template for the ser- vice. SEE ALSO
libslp(3N). SLPError(3N)
All times are GMT -4. The time now is 08:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy