remove a colon and number and leaving the rest


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting remove a colon and number and leaving the rest
# 1  
Old 08-06-2008
remove a colon and number and leaving the rest

just have a file

1:
2333 2:-09393 [B]3:[/B]45453 4:-09999 5:-09933 6:93939

question is to get output by removing colons as well as number before each colon (in bold)

2333 -09393 45453 -09999 09933 93939
# 2  
Old 08-06-2008
Code:
echo "1:2333 2:-09393 3:45453 4:-09999 5:-09933 6:93939" | sed 's/[0-9]://g'
# in a file
sed 's/[0-9]://g' file > newfile

# 3  
Old 08-06-2008
one more question

Thanks tht command will help to remove when u have start from 0-9

what happen when u have after 10 uptp 50 and want to have to remove that part.

11:2222 12:3333 13 :-222 ...so on

when tried using the same sed[0-9]://g

then get output 12222 23333 3-222

so alternate option........
# 4  
Old 08-06-2008
Try using split on ":" and printing out part 2

split($0,a,":"); print a[2]
# 5  
Old 08-06-2008
echo "1:2333 2:-09393 3:45453 4:-09999 5:-09933 6:93939" | tr -d ":"

the above also will do..

-ilan
# 6  
Old 08-07-2008
Code:
cat filename | sed 's/[0-9]*://g'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk to remove mutiple values from specific pattern, leaving a single value

In the awk below I am trying to remove all instances after a ; (semi-colon) or , (comma) in the ANN= pattern. I am using gsub to substitute an empty string in these, so that ANN= is a single value (with only one value in it the one right after the ANN=). Thank you :). I have comented my awk and... (11 Replies)
Discussion started by: cmccabe
11 Replies

2. Solaris

Remove number in file name

Hi , i have a file name with date and time append like test_SEC_AES_V1_T03_2016031404306 i want to remove the date and time after _ and rename to current date and time,can any one please let me know as i tried some options but din't help:( Thanks, Please use code tags as required... (10 Replies)
Discussion started by: caba_jones
10 Replies

3. Shell Programming and Scripting

Remove last number from a file

Hi, I need to delete last number ( i.e 126) from the file which has below contents. ABC DEF "XYZ" 2837.5 3852.5 126 ABC DEF "XYZ" 2897.5 3852.5 126 ABC DEF "XYZ" 2957.5 3852.5 126 Please help. Thanks in advance. (17 Replies)
Discussion started by: gujrathinr
17 Replies

4. Shell Programming and Scripting

Remove last occurrence of character (_) and rest of the string in UNIX (sed)

Hi I need help on this ..!! Input : xx_abc_regA xx_def_regB xx_qwe_regC Now i required the output as the below abc def qwe Need to remove last occurrence of character (_) and rest of the string in Unix (sed). Thanks in Advance ..!!! -Nallachand (3 Replies)
Discussion started by: Nallachand
3 Replies

5. Shell Programming and Scripting

Bash, remove numbers after colon

Hello All, I was wondering if someone might know how to do this. I have a word list that is format like the example below. I need to take away the :number after that... is there some kind of command I could use to remove them? 123456:5562 password:1507 123456789:989 qwerty:877... (7 Replies)
Discussion started by: 3therk1ll
7 Replies

6. Shell Programming and Scripting

awk delete/remove rest of line on multiple search pattern

Need to remove rest of line after the equals sign on search pattern from the searchfile. Can anybody help. Couldn't find any similar example in the forum: infile: 64_1535: Delm. = 86 var, aaga 64_1535: Fran. = 57 ex. ccc 64_1639: Feb. = 26 (link). def 64_1817: mar. = 3/4. drz ... (7 Replies)
Discussion started by: sdf
7 Replies

7. Shell Programming and Scripting

Remove char after Colon

Hi guys, This is my input 2735:<7001> 34 789 701 2 2774:<7001> 34 789 701 2 How to delete characters after colon : Including colon : too ? My output should... (3 Replies)
Discussion started by: gowrishankar05
3 Replies

8. Shell Programming and Scripting

Remove lines of the same time stamp leaving the highest

Hi guys, I have a log that looks like that below. Columns 2 3 4 5 6 7 is the date/time stamp separated by comma. UUU,02,06,2010,10,00,00,00,0000000000000000,0000000000000000,0000000000001224 UUU,02,06,2010,10,05,00,00,0000000000000000,0000000000000000,0000000000001502... (2 Replies)
Discussion started by: borderblaster
2 Replies

9. Shell Programming and Scripting

Remove text between headers while leaving headers intact

Hi, I'm trying to strip all lines between two headers in a file: ### BEGIN ### Text to remove, contains all kinds of characters ... Antispyware-Downloadserver.com (Germany)=http://www.antispyware-downloadserver.c om/updates/ Antispyware-Downloadserver.com #2... (3 Replies)
Discussion started by: Trones
3 Replies

10. Shell Programming and Scripting

Need to only remove parenthesis and : leave the rest

Hi all, I'm stuck on this last part...am running a simple script under AIX to extract NetView host IP addresses. The line below returns the IP address in parenthesis with a trailing colon, i.e. ping -c 1 $name |grep \( | awk '{ print $3 }' --------> returns (a.b.c.d): How can I only... (10 Replies)
Discussion started by: livinthedream
10 Replies
Login or Register to Ask a Question