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
LDIF(5) 							File Formats Manual							   LDIF(5)

NAME
ldif - LDAP Data Interchange Format DESCRIPTION
The LDAP Data Interchange Format (LDIF) is used to represent LDAP entries in text form. LDAP tools, such as ldapadd(1) and ldapsearch(1), read and write LDIF. The basic form of an LDIF entry is: dn: <distinguished name> <attrdesc>: <attrvalue> <attrdesc>: <attrvalue> <attrdesc>:: <base64-encoded-value> <attrdesc>:< <URL> ... The value may be specified as UTF-8 text or as base64 encoded data, or a URI may be provided to the location of the attribute value. A line may be continued by starting the next line with a single space or tab, e.g., dn: cn=Barbara J Jensen,dc=exam ple,dc=com Lines beginning with a sharpe sign ('#') are ignored. Multiple attribute values are specified on separate lines, e.g., cn: Barbara J Jensen cn: Babs Jensen If an value contains a non-printing character, or begins with a space or a colon ':', the <attrtype> is followed by a double colon and the value is encoded in base 64 notation. e.g., the value " begins with a space" would be encoded like this: cn:: IGJlZ2lucyB3aXRoIGEgc3BhY2U= If the attribute value is located in a file, the <attrtype> is followed by a ':<' and a file: URI. e.g., the value contained in the file /tmp/value would be listed like this: cn:< file:///tmp/value Other URI schemes (ftp,http) may be supported as well. Multiple entries within the same LDIF file are separated by blank lines. EXAMPLE
Here is an example of an LDIF file containing three entries. dn: cn=Barbara J Jensen,dc=example,dc=com cn: Barbara J Jensen cn: Babs Jensen objectclass: person description:< file://tmp/babs sn: Jensen dn: cn=Bjorn J Jensen,dc=example,dc=com cn: Bjorn J Jensen cn: Bjorn Jensen objectclass: person sn: Jensen dn: cn=Jennifer J Jensen,dc=example,dc=com cn: Jennifer J Jensen cn: Jennifer Jensen objectclass: person sn: Jensen jpegPhoto:: /9j/4AAQSkZJRgABAAAAAQABAAD/2wBDABALD A4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQ ERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVG ... Notice that the description in Barbara Jensen's entry is read from file://tmp/babs and the jpegPhoto in Jennifer Jensen's entry is encoded using base 64. SEE ALSO
ldap(3), ldapsearch(1), ldapadd(1). "LDAP Data Interchange Format," Good, G., RFC 2849. ACKNOWLEDGEMENTS
OpenLDAP is developed and maintained by The OpenLDAP Project (http://www.openldap.org/). OpenLDAP is derived from University of Michigan LDAP 3.3 Release. OpenLDAP 2.1.X RELEASEDATE LDIF(5)
All times are GMT -4. The time now is 10:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy