Print after colon


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Print after colon
# 1  
Old 03-12-2015
Print after colon

I have entries like below in a file
Code:
11.22.33.44:80
22.33.44.55:81
:::587
:::465

What I need is to take out the part after colon ( : )
Output should be as follows.
Code:
80
81
587
465

I used cut -d: -f 2 but its not working as dedired.
# 2  
Old 03-12-2015
Code:
sed 's/.*://' <datafile.txt

This User Gave Thanks to cjcox For This Post:
# 3  
Old 03-12-2015
Thanks it worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merging and Adding colon to columns

Hello, I have a tab delim file that looks like this CHROM POS ID REF ALT ID HGVS_C HGVS_P 1 17319011 rs2076603 G A NM_022089.3,NM_001141973.2,NM_001141974.2 c.1815C>T,c.1800C>T,c.1800C>T p.Pro605Pro,p.Pro600Pro,p.Pro600Pro 1 20960230 rs45530340 ... (3 Replies)
Discussion started by: nans
3 Replies

2. UNIX for Beginners Questions & Answers

How to print string after colon?

Hi How do I print character after colon":" below is input file BUC1 : 33157147, BUC1 COUNT : 478455,BUC1 : 9930334.18 BUC2 : 1203100,BUC2 COUNT : 318678,BUC2 GIVEN : 3493491.59 BUC3 : 234567.99 expected output 33157147 478455 9930334.18 12031002 318678 3493491.59 234567.99 (10 Replies)
Discussion started by: scriptor
10 Replies

3. Shell Programming and Scripting

Use of colon

There was a sample code on forum I found sometime back: $ f() { local foo=; : ${foo=unset}; declare -p foo; }; f declare -- foo="" $ f() { local foo; : ${foo=unset}; declare -p foo; }; f declare -- foo="unset" Can someone explain why was colon (:) is being used here. Whats its use? (4 Replies)
Discussion started by: Rameshck
4 Replies

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

5. Shell Programming and Scripting

Sort numbers which has colon (:) in between

Although i tried multiple option i couldn't find a way to get the rigt ouput. Say i have the following data cat file.txt C request C response C request C response The output should look like (9 Replies)
Discussion started by: varu0612
9 Replies

6. Shell Programming and Scripting

Colon in awk script output

I'm using AIX 5.3 and running a awk replace to modify data as follows: echo 1234: 1234 123 123 444 555 666 7777 | awk '/^:/{split($2,N);n=N} {n=$1} {sub(n,n+10000000)}1' 10001234 1234 123 123 444 555 666 7777 dumb question.. how do I get the colon back in, so it outputs 10001234: 1234... (4 Replies)
Discussion started by: say170
4 Replies

7. UNIX for Dummies Questions & Answers

Why do we use a colon (:) in grep?

Can some one please explain why do we use colon in a grep statement . for eg: ORACLE_SID=$(grep :$(echo $JOBNAME |cut -c1-3): ${SWENV_TAB}|awk -F: '{print $1}') Thanks in advance Sri (5 Replies)
Discussion started by: Sri3001
5 Replies

8. UNIX for Dummies Questions & Answers

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: --------- A~000000000000518000~SLP:~99991231~20090701~00102.00~USD:~CS:~... (2 Replies)
Discussion started by: chumsky
2 Replies

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

10. Solaris

how to delimit a colon

I want to know how to delimit a colon in a file name while scp ing from one host to other host. I used forward slash(\) but that is not working. (1 Reply)
Discussion started by: rogerben
1 Replies
Login or Register to Ask a Question