awk --posix -F"[^A-Z0-9-]" '{for(i=1;i<=NF;i++){if($i~/^[A-Z][A-Z]{3}-[0-9]{5}/){print $i} }}' test.txt
This should do , what your are looking for. Please test and let me know
awk --posix -F"[^A-Z0-9-]" '{for(i=1;i<=NF;i++){if($i~/^[A-Z][A-Z]{3}-[0-9]{5}/){print $i} }}' test.txt
This should do , what your are looking for. Please test and let me know
@above
don't know
see below
echo GAPI-53137 | awk --posix -F"[^A-Z0-9-]" '{for(i=1;i<=NF;i++){if($i~/^[A-Z][A-Z]{3}-[0-9]{5}/){print $i} }}'
does not give me anything when i tested
I am not manipulating anything here, it worked fine in Solaris and Linux.
cgi@tonga> (/home/cgi) $ echo GAPI-53137 | awk --posix -F"[^A-Z0-9-]" '{for(i=1;i<=NF;i++){if($i~/^[A-Z][A-Z]{3}-[0-9]{5}/){print $i} }}'
GAPI-53137
cgi@tonga> (/home/cgi) $
cgi@tonga> (/home/cgi) $
Try this inyour machine and post the output
echo GAPI-53137 | awk --posix -F"[^A-Z0-9-]" '{print $1}'
hey seriously it is not giving me anything
[EMAIL="amzanjad@q4de3msys05"]
/home
$ echo GAPI-53137 | awk --posix -F"[^A-Z0-9-]" '{for(i=1;i<=NF;i++){if($i~/^[A-Z][A-Z]{3}-[0-9]{5}/){print $i} }}'
/home
$
[/EMAIL]
---------- Post updated at 05:32 AM ---------- Previous update was at 05:32 AM ----------
ny idea hw can we go further
Pleaes post the output you are getting and also the awk version using
awk --version
echo GAPI-53137 | awk --posix -F"[^A-Z0-9-]" '{print $1}'
/home
$ echo GAPI-53137 | awk --posix -F"[^A-Z0-9-]" '{print $1}'
GAPI-53137
/home
$ awk --version
in that case it hangs tried two times smthing is wrong here
It seems that standard awk in solaris doesn't support such expression matching ( re-interval one)
At least i hope this works
echo GAPI-53137 | awk --posix -F"[^A-Z0-9-]" '{for(i=1;i<=NF;i++){if($i~/^[A-Z][A-Z][A-Z][A-Z]-[0-9][0-9][0-9][0-9][0-9]/){print $i} }}'
Please say it works
@above
hey it works
and ur right re-interval is not working here
so can u please please explain the sol't and whether it si applicable for all the scenario for my input file
please m waiting for ur reply..
Finally we made it
Solution is simple , but you forced lot of restrictions like, only in awk and no gawk .
First i separate the fields in the input but without splitting our intended error code. Once that is done, then i am validating field by field to match the regex,and print if it matches.
hey
one bad news yaar
echo :GAPI-12345 | awk --posix -F"[^A-Z0-9-]" '{for(i=1;i<=NF;i++){if($i~/^[A-Z][A-Z][A-Z][A-Z]-[0-9][0-9][0-9][0-9][0-9]/){print $i} }}'
and it too returns nothing
actually i have to search that preceds "GAPI" there should not be any alpha character.
Oh !
awk doesn't even recognize the separator proper. Why not gawk ??
cgi@tonga> (/home/cgi) $ echo :GAPI-12345 |gawk --posix -F"[^A-Z0-9-]" '{print NF}'
2
cgi@tonga> (/home/cgi) $ echo :GAPI-12345 |/bin/awk --posix -F"[^A-Z0-9-]" '{print NF}'
1
cgi@tonga> (/home/cgi) $
gawk is not installed .. nyways leave it
thanks for ur support
really appreciated
i have thing another approach to modify the file ..
thanks once again