Results 1 to 4 of 4
hey, well that helped me a lot as well, I have another question.. let's say I have the following:
24 Jun 2010 02:14:38,686 - INFO - Sending to SMPP ENGINE..................................(TID=20134 ...
- 06-24-2010 #1Just Joined!
- Join Date
- Jun 2010
- Posts
- 3
want to return the corresponding time
hey, well that helped me a lot as well, I have another question.. let's say I have the following:
24 Jun 2010 02:14:38,686 - INFO - Sending to SMPP ENGINE..................................(TID=20134 22, Mobile No.=96171543122,
If I put 961........ it will return all the numbers, which is perfect, but if i want to return the corresponding time, how should I put it?
I tried the following:
sed -n 's/^\(.*\)\(961........\)\(..:..:..\)\(.*\)$/\2/p' THETESTER
but it's not returning anything. I feel the solution is rather silly but I cannot see it, any help? excuse my ignorance, im still a noob
- 06-24-2010 #2
The match just does not match. :P
Split it up: ^\(.*\)\(961........\)\(..:..:..\)\(.*\)$
1] ^ start of line
2] (.*) every character
3] (961........) characters with leading 961 and a fixed number of other characters behind (the dots)
4] (..:..:..) would then match a time
5] (.*) and yet all the rest of the line
6] $ until reached the end of line
Now look at your example and I'm sure you can figure it out on your own.
- 06-24-2010 #3Just Joined!
- Join Date
- Jun 2010
- Posts
- 3
What I want as output is the following:
02:14:38 96171543122
I dont know why it's giving me headaches, I tried to split them but no success whatsovever
grrrrr
- 06-25-2010 #4
I suppose you thought about it for more than just 5 seconds, so this clue may help you on:
The line should be matched like this:
1] ^ start of line
2] (.. ... .... ..:..:..,...) group that matches the date
3] .* skip the next few characters
4] [Mobile\ No\.\=([0-9]*)] matches the part you want (the mobile number)
Finally you reference the groups you have in there (if you assemblied all parts group 1 is the date, group 2 is the mobile number. So what is the sed command it should look alike in the end?
's/^(.. ... .... ..:..:..,...).*[Mobile\ No\.\=([0-9]*)]\/\1 \2/p'
Did you understand what you did wrong?
PS: this is untested, so generally said it will not work by copy&paste. Some things can be teached and some things you have to figure out on yourself.


Reply With Quote