Read a file content with awk and sed

Hello ,

I have huge file with below content. I need to read the numeric values with in the paranthesis after = sign. Please help me with awk and sed script for it.

11.10.2009 04:02:47 Customer login not found: identifier=(0748502889) prefix=(TEL) serviceCode=().
11.10.2009 04:03:12 Customer login not found: identifier=(0162707245) prefix=(TEL) serviceCode=().
11.10.2009 04:03:12

Thanks in advance

Try this:

 awk -F"[()]" '{print $2}' file
awk 'BEGIN{FS=")"}
{
   for (i=1;i<NF;i++){
    gsub(/.*\(/,"",$i)
    if($i ~ /[0-9]+/) print $i
   }
}' file

Hello,

I could not get any output for the first awk script.
For the second one
awk 'BEGIN{FS=")"}
> {
> for (i=1;i<NF;i++){
> gsub(/.*\(/,"",$i)
> if($i ~ /[0-9]+/) print $i
> }
> }' ListofLoginIds.txt

awk: syntax error near line 4
awk: illegal statement near line 4

Please help.

which OS are you using??
try using nawk.. or else use Franklin's solution that will also do..

I am using Solaris.
Franklins solution is only giving empty output.

That means the sample data what you have provided won't match with the actual file content.. please verify...
because for the sample input both code works perfectly..

Hello ,

Please find the sample data that I using in the attachment.

see the o/p for your sample input file..

fnsonlu1-/home/> cat sample.txt
06.09.2009 18:07:01 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
06.09.2009 18:10:37 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
06.09.2009 18:10:37 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
07.09.2009 06:02:08 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
07.09.2009 06:02:08 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
07.09.2009 18:20:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
07.09.2009 18:20:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
08.09.2009 06:00:52 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
08.09.2009 06:00:52 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
08.09.2009 06:05:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
08.09.2009 06:05:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
08.09.2009 18:12:57 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
fnsonlu1-/home/> awk -F"[()]" '{print $2}' sample.txt
0499472147
0499472147
0499472147
0165599574
0165599574
0165599574
0165599574
0499472147
0499472147
0165599574
0165599574
0499472147
fnsonlu1-/home/fnsonlu1>

Is there anything wrong in what I did ?

/usr/people/wrajyasm$ cat sample.txt
06.09.2009 18:07:01 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
06.09.2009 18:10:37 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
06.09.2009 18:10:37 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
07.09.2009 06:02:08 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
07.09.2009 06:02:08 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
07.09.2009 18:20:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
07.09.2009 18:20:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
08.09.2009 06:00:52 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
08.09.2009 06:00:52 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
08.09.2009 06:05:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
08.09.2009 06:05:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
08.09.2009 18:12:57 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
/usr/people/wrajyasm$ awk -F"[()]" '{print $3}' sample.txt

/usr/people/wrajyasm$

awk -F"[()]" '{print $2}' sample.txt

cat sample.txt
06.09.2009 18:07:01 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
06.09.2009 18:10:37 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
06.09.2009 18:10:37 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
07.09.2009 06:02:08 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
07.09.2009 06:02:08 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
07.09.2009 18:20:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
07.09.2009 18:20:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
08.09.2009 06:00:52 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
08.09.2009 06:00:52 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
08.09.2009 06:05:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
08.09.2009 06:05:28 Customer login not found: identifier=(0165599574) prefix=(TEL) serviceCode=().
08.09.2009 18:12:57 Customer login not found: identifier=(0499472147) prefix=(TEL) serviceCode=().
/usr/people/wrajyasm$ awk -F"[()]" '{print $2}' sample.txt

/usr/people/wrajyasm$

Even then I am not getting any output .Please help.

what is wrong ?

# awk 'BEGIN{FS=")"}{ for (i=1;i<NF;i++){ gsub(/.*\(/,"",$i) ;if($i ~ /[0-9]+/) print $i}}' file
0499472147
0499472147
0499472147
0165599574
0165599574
0165599574
0165599574
0499472147
0499472147
0165599574
0165599574
0499472147

It works perfectly on Solaris.

Did you try nawk as suggested, or /usr/xpg4/bin/awk?