Get the words..

Hi All,

I'm a newbie with scripting.
Can you help me on how to get the 'zekmsam221_0730.log' string from this string?

zekmsam221_0730.log:ORA-00942: table or view does not exist

Thanks,
Jet

Try:

echo "zekmsam221_0730.log:ORA-00942:" | cut -d: -f1
line="zekmsam221_0730.log:ORA-00942:"
file=${file%%:*}
echo file
$ echo "zekmsam221_0730.log:ORA-00942:" | sed 's/^\([^:]*\):.*$/\1/'
zekmsam221_0730.log

Thanks for the reply.
Can we make it more flexible? Let say we don't know the 'zekmsam221_0730.log' string but we know that there is always an 'ORA-' after 'zekmsam221_0730.log' string.
Is it still possible to get the string before the ':ORA-...'?

string=zekmsam221_0730.log:ORA-00942:
echo ${string%%:ORA*}

vino,
it didn't work.
do i have to replace something in you code?

I cannot say anything unless I see what is happening at your end. If you can post the code you gave and the result you got, probably I can help you out.

i placed your code in test.log file
then type in the commandline.. test.log

vino,
thanks! I think I got it now.

$ echo "zekmsam221_0730.log:ORA-00942:" | sed 's/^\(.*\):ORA-.*$/\1/'
zekmsam221_0730.log