replace multiple existence of : symbol with one


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting replace multiple existence of : symbol with one
# 1  
Old 04-11-2011
replace multiple existence of : symbol with one

Infile

Quote:
policy:::cngptpid
policy:::budget87
policy:::cntrstat
Outfile
Quote:
policy:cngptpid
policy:budget87
policy:cntrstat
# 2  
Old 04-11-2011
sed 's/\([^:]*\):*\([^*]*\)/\1:\2/'
# 3  
Old 04-11-2011
Code:
cat infile | tr -s ":" > outfile

# 4  
Old 04-11-2011
awk 'BEGIN { FS=":*";OFS=":" } { print $1,$2 }
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove/replace the very first character/symbol match

cat file.txt file 1123.x July 23:222 /cd/hh2/k39/ss2/f7d8d9d8e6r5t4s/dd2/e/s7a/s7a2afa5017d8b975-1.7-1395610245-b22e19bbc477b134 i wish to only extract out the 1.7 (anything within the first - -) i try to look for the sed command under match the first occurence of pattern but out of luck, my... (6 Replies)
Discussion started by: ctphua
6 Replies

2. Shell Programming and Scripting

Replace trailing whitespaces with pipe symbol using perl

I want to replace the whitespace with Pipe symbol to do a multiple pattern matching for the whole text "mysqld failed start" and same as for other text messages Below are the messages stored in a file seperate by whitespace mysqld failed start nfsd mount failed rpcbind failed to start for... (6 Replies)
Discussion started by: kar_333
6 Replies

3. UNIX for Dummies Questions & Answers

To replace '(' and ')' symbol using tr or sed

I am trying to replace '(' and ')' symbol with nul text using tr command. But i am not able to get the expected output . Please help # cat test.txt 155170816-(75767Mb) # tr '(' '' < test.txt 155170816-(75767Mb) # tr ')' '' < test.txt 155170816-(75767Mb) # I want the o/p as ... (8 Replies)
Discussion started by: thomasraj87
8 Replies

4. Shell Programming and Scripting

How to replace quote symbol(") and dot(.) with some other values!!

Hi , I have below input file 1.order number is useful. 2.vendor_id is produced. 3.the vandor name is "malawar". I want output file like 1. order number is useful. 2. vendor_id is produced. 3. the vandor name is VmalawarV. in input file line number 1.order number there is no... (4 Replies)
Discussion started by: vinothsekark
4 Replies

5. Shell Programming and Scripting

Script needed to wait for existence of multiple files

Hi Forum. I need a script to wait for all multiple trigger files to be present or else go to sleep for 10 seconds (Number of trigger files can vary). I tried to search on the forum but was not able to find a solution. I found this code on this forum but it's not working as expected: for... (6 Replies)
Discussion started by: pchang
6 Replies

6. Windows & DOS: Issues & Discussions

Replace first existence of any character using DOS

Hi I want to replace first existence of the character code I m using is for /f "tokens=* delims= " %%a in (test2.csv) do ( set str=%%a echo !str::=,! >> test3.csv ) However it is replacing all the ':' whereas I want to replace first ':' by ',' and leave rest of the ':' as it is. ... (0 Replies)
Discussion started by: dashing201
0 Replies

7. Linux

Replace cloud symbol with single quotes

Dear Experts My source file contains the symbol cloud (☁). How do i replace this ☁ symbol whose Unicode value is 2601 in linux file with single quotes ? Any help will be much appreciated. Many thanks (4 Replies)
Discussion started by: pklcnu
4 Replies

8. Shell Programming and Scripting

replace a symbol with new line

i have file in which i want to replace a char with new line please help me out (1 Reply)
Discussion started by: RahulJoshi
1 Replies

9. Shell Programming and Scripting

Checking Multiple file existence

Hi, I want to check multiple files exist or not in a single if statement in korn Shell:confused:. Please help me Thanks (1 Reply)
Discussion started by: lathish
1 Replies

10. Shell Programming and Scripting

verifying existence of multiple files

Hi, I have unix script on solaris 5.10. I have to verify existence of 3 files in path and sleep for 1 hour. I have tried for 1 file: if then echo " File is found!" sleep 3600 echo "time delayed" fi Please advice (6 Replies)
Discussion started by: ammu
6 Replies
Login or Register to Ask a Question