help with grep command

i have the following lines
T2345
T3435 - bugfixed and running
T5654 fixed and committed
T34541:- fixed and committed

i need to extract only the T[0-9] part (eg:T2345) ,ie i dont want any special characters after it.

i have been trying with grep and egrep but with no luck.
pls help

bash-3.00$ nawk -F"[ \:]" '{print $1}' /tmp/myfile
T2345
T3435
T5654
T34541

Or:

sed 's/\(.[0-9]*\).*/\1/' file

tanx guys...:b:
I tried both the commands and it worked.....
I also got the same result by using grep

grep -o "^T[0-9]*" pmt.txt 

there is one more thing,there are lines like these in my text file

T7310,T7311
T0000
T0000
T7325
T7328:Provide Employee Group classification in Attendance confirmation screen, Mark Attendance Screens  and leave Encashment Screen.
T7307
T7209
T7279
T6976,T6869

i want the comma(,) separated ones (T6976,T6869) intact,means i want to
keep the comma separated ones unchanged

P.S:i am beginning to enjoy scripting :slight_smile:

This should work...

 sed '/T\([0-9]*\),[A-Z]/ !s/\(.[0-9]*\).*/\1/' inputfile

Thanks
Sha

egrep -o '(T[0-9]+,?)*' pmt.txt

It becomes adictive

tanx guyzz...:b:

i have a file which lists the following
T2323
T3445
T67666,T6534

i need to extract the numeric part only(ie,without T).
I have been trying with grep and egrep but with noluck
pls help

try this

nawk -F"[ \:]" '{print substr($1,2,length($1)}' /tmp/myfile

Ok,i tried this script

awk '{print substr($0,2,length($0))}' pmt2.txt 

Output

2323
3445
67666,T6534,T4546

as u can see the numbers coming after "," remains the same(the code didn't affect them ) :confused:.I need all the T's removed from thr file.

P.s:nawk is not working in my machine

egrep -o '(T[0-9]+,?)*' pmt.txt | sed 's/[^0-9,]//g'

tr -cd ',[:digit:]'

Regards,
Alister