how to cut prefix from a string

I have a file:

chromosome1:436728
chromosome2:32892
.....
chromosome22:23781

I just want to get the number, not the prefix "chromosomeX", so I want to remove all the prefix ahead of the numbers. How can I do that?? Thanks!!! (PS: give me some very simple command so that I can understand it... :frowning: )

Try this :'

cat yourfile | cut -d":"  -f2

Either

$ awk -F':' '{print $2}' infile > outfile

or

$ sed -e 's/^.*://' infile > outfile

The first one splits every input line on the ':' character and prints out the second field. The second will replace any characters from the beginning of the line up to and including the ':' with nothing.

@ce9888: Useless use of cat. cut can read from a file just fine by itself, eg 'cut -d ":" -f 2 infile'

Thanks a lot! Really a easy way!

Thanks a lot, too!!