separate two numbers separated by :


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting separate two numbers separated by :
# 1  
Old 03-10-2011
separate two numbers separated by :

Hi all
i have a data of this form
Code:
10.12.4.22:138
10.12.2.50:137
10.20.2.24:1027
10.12.2.44:138
10.12.2.44:137
10.0.4.38:58871
10.13.3.19:138


i need to separate the number out which is at the last and after ':'

Please help me out

Thanx in advance

Last edited by Franklin52; 03-10-2011 at 09:18 AM.. Reason: Please use code tags, thank you
# 2  
Old 03-10-2011
Code:
cut -d: -f2 file

This User Gave Thanks to bartus11 For This Post:
# 3  
Old 03-10-2011
Another approach:
Code:
while IFS= read string
do
  echo ${string##*:}
done < file

This User Gave Thanks to Franklin52 For This Post:
# 4  
Old 03-10-2011
Code:
awk -F: '{print $2}' infile

sed 's/.*:\(.*\)/\1/' infile

# 5  
Old 03-11-2011
Another sed way..
Code:
sed 's/.*://' inputfile > outfile

# 6  
Old 03-11-2011
TRY WITH BOTH

Code:
awk -F":" '{print $2}' File_Name

Code:
cut -d":" -f2 File_Name

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

[solved] Comma separated values to space separated

Hi, I have a large number of files which are written as csv (comma-separated values). Does anyone know of simple sed/awk command do achieve this? Thanks! ---------- Post updated at 10:59 AM ---------- Previous update was at 10:54 AM ---------- Guess I asked this too soon. Found the... (0 Replies)
Discussion started by: lost.identity
0 Replies

2. Shell Programming and Scripting

Help awk/sed: putting a space after numbers:to separate number and characters.

Hi Experts, How to sepearate the list digit with letters : with a space from where the letters begins, or other words from where the digits ended. file 52087mo(enbatl) 52049mo(enbatl) 52085mo(enbatl) 25051mo(enbatl) The output should be looks like: 52087 mo(enbatl) 52049... (10 Replies)
Discussion started by: rveri
10 Replies

3. Shell Programming and Scripting

Separate two numbers

I would like to separate number by space so that 121231212 222111212 would be 1 2 1 2 3 1 2 1 2 2 2 2 1 1 1 2 1 2 Thanks! (2 Replies)
Discussion started by: johnkim0806
2 Replies

4. Shell Programming and Scripting

separate numbers in a file

I have this command in a shl (UNIX) to find the lates file that start with EMT in a directory file=$(ls -tr $EMT*.dat | tail -1) # Select the latest file It finds: EMT345.dat then I have to be able to separate EMT AND the numbers 345 and stored 345 in a variable and incremented, so my new... (7 Replies)
Discussion started by: rechever
7 Replies

5. Shell Programming and Scripting

AWK to separate numbers from logs

Hello friends, Im trying to separate a number from a log, but it seems i need help here awk '/stimated/ {print $5}' mylog.txt gives (1515.45MB). i need pure number part to use in a comparision loop so i want to separate the number part (but only 1515 not 1515.45 ) awk '/stimated/... (6 Replies)
Discussion started by: EAGL€
6 Replies

6. Shell Programming and Scripting

reverse ':' separated numbers in a shell script

I want to reverse a the following: 00:11:22:33:44:55 I currently use something like below to pass it as is. But now I want the same script to reverse the above and pass it to ethtool. // psuedo code i=0 skip=0 for m in $@ do if then skip=1 ... (1 Reply)
Discussion started by: bhanu.nani
1 Replies

7. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

8. UNIX for Dummies Questions & Answers

validate a pattern of numbers that are comma separated

Hi, I have a requirement wherein, I need to validate a user input of the numbers that are comma separated. E.g . The input should be in the format 1,2,3...n (count of numbers is not known) . The user has to mention the input in this format, else it should exit from the program. ... (5 Replies)
Discussion started by: 12345
5 Replies

9. UNIX for Dummies Questions & Answers

how to separate numbers and words from a file using shell scripts

Hi, How to separate numbers and words(with full alphabets) in a particular file and store it in two different files. Please help me out for this.Using shell scripting. :confused::confused: (1 Reply)
Discussion started by: kamakshi s
1 Replies

10. Shell Programming and Scripting

Separate lines in a single '|' separated line

Hi I have a file with contents like china india france japan italy germany . . . . etc.... I want the output as china|india|france|japan|italy|germany|.|.|. (3 Replies)
Discussion started by: hidnana
3 Replies
Login or Register to Ask a Question