hi if would like to get the phone number as an output, can you guide me here please
<A>213444555</A><B><B>ABCDEFG</B>
I just want to get the phone number from the file in between <A> and </A>
Thanks
hi if would like to get the phone number as an output, can you guide me here please
<A>213444555</A><B><B>ABCDEFG</B>
I just want to get the phone number from the file in between <A> and </A>
Thanks
what have you tried??
Thanks for the reply
I have tried the following
cat test|awk -F '<' '{print $1}'|grep '[0-9]\{2\}'
cat test|grep '\<"<A>[0-9]</A>"\>'
test file has the value in it
use sed
sed 's/\(<A>\)\([0-9]*[0-9]\)\(.*\)/\2/g' test
or
sed 's/<A>\([0-9]*[0-9]\)\(.*\)/\1/g' test
Thanks Very much, should it work for Alphebets by changing
0-9 to A-Z?
Thanks again
yes it will but where and what you want to extract depending on that use it
Thanks again Vidya, just one more thing, if you could explain the following part, i will really appereciate it
's/<A>\([0-9]*[0-9]\)\(.*\)/\1/g' and what difference does 2 make instead of one while replaceing it
sed 's/\(<A>\)\([0-9]*[0-9]\)\(.*\)/\2/g'
Thanks Again
-----Post Update-----
hi Again
sorry but this is what I was exactly trying to get from the following output but I thought that piece of code would work but didnt work for the following output
! TICKET NBR : 2 ! GSI : 23 ! 111111111 PPDBEP1 ! 356411158 RI:12 ! 3100.2.22.1 MTC ! 3100.2.20.1 4034673533 ! 3100.2.13.1 0.0
0 ! 3100.2.14.2 1348 ! 1.2.1.8 <A>1001001265856</A><B>ABCMobile</B><C>9999999</C><D>9999</D><E></E><F>CALGARY AB</
F><G>722X _CALGARY AB</G><H>99999</H><I>D212</I><J>09/06/2009 21:37:40</J><Q></Q><R>P1_T1_LOCAL</R><K>RL 0.00/60/60 QL 1380 C
i wanted to get abc mobile by itself form the output please
\1 and \2 represents the holding buffer in sed
in first case <A> is not stored in holding buffer and \([0-9]*[0-9]\) will be stored in holding buffer 1 so replaced the whole line with content of holding buffer 1
in second case <A> is stored in holding buffer 1 and tel no in 2 and replaced whole line with that of 2
if you have Python,
#!/usr/bin/env python
data=open("output").read()
st=data.index("<B>")
en=data.index("</B>")
print data[st+3:en]
the final solution also depends on how the rest of your file looks like. the above uses <B> and </B> as unique indicators, as according to your sample.
Thanks very much vidyadhar85 and ghostdog74