Hi
I need to to direct only the path and the name of the trace file to a new file. How do I use grep/awk/sed filter?
eg.
ABC.root>cat alert_omc_dg.log | grep trc
ORA-00060: Deadlock detected. More info in file /u01/oradata/omc/udump/omc_dg_ora_3555.trc.
ORA-00060: Deadlock detected. More info in file /u01/oradata/omc/udump/omc_dg_ora_26570.trc.
ORA-00060: Deadlock detected. More info in file /u01/oradata/omc/udump/omc_dg_ora_13896.trc.
Errors in file /u01/oradata/omc/udump/omc_dg_ora_24462.trc:
ORA-00060: Deadlock detected. More info in file /u01/oradata/omc/udump/omc_dg_ora_565.trc.
ORA-00060: Deadlock detected. More info in file /u01/oradata/omc/udump/omc_dg_ora_20888.trc.
$> cat infile
ORA-00060: Deadlock detected. More info in file /u01/oradata/omc/udump/omc_dg_ora_3555.trc.
ORA-00060: Deadlock detected. More info in file /u01/oradata/omc/udump/omc_dg_ora_26570.trc.
ORA-00060: Deadlock detected. More info in file /u01/oradata/omc/udump/omc_dg_ora_13896.trc.
Errors in file /u01/oradata/omc/udump/omc_dg_ora_24462.trc:
ORA-00060: Deadlock detected. More info in file /u01/oradata/omc/udump/omc_dg_ora_565.trc.
ORA-00060: Deadlock detected. More info in file /u01/oradata/omc/udump/omc_dg_ora_20888.trc.
$> sed 's/.*file.\(.*\.trc\).*/\1/' infile > newfile
/u01/oradata/omc/udump/omc_dg_ora_3555.trc
/u01/oradata/omc/udump/omc_dg_ora_26570.trc
/u01/oradata/omc/udump/omc_dg_ora_13896.trc
/u01/oradata/omc/udump/omc_dg_ora_24462.trc
/u01/oradata/omc/udump/omc_dg_ora_565.trc
/u01/oradata/omc/udump/omc_dg_ora_20888.trc
Works with GNU sed and awk on AIX.
---------- Post updated at 05:13 PM ---------- Previous update was at 05:11 PM ----------
For Pludi's awk you can do this so you don't need to pipe into cut:
Thanks from me too Zaxxon. I use '-e' quite a bit, because I usually have more than one pattern to find, but that's not the OP's requirements. Good catch on the trailing '.' and ':' and a big "D'oh!" from me for forgetting the input file!
The '-n' and 'p' though I felt were needed since the OP was going through an oracle alert log, which usually contain lines other than those the OP "grep'ed" out of them.
So in order to simply process the whole alertlog and not have to pre "grep" it I figured I'd toss in the '-n' to hold off printing and the 'p' to print only that which fit the pattern to the newfile.
Unfortunately in my rush I didn't state what I was hoping to perform.