Sponsored Content
Top Forums Shell Programming and Scripting Need to build a grep/sed/awk filter Post 302408751 by zaxxon on Tuesday 30th of March 2010 11:13:40 AM
Old 03-30-2010
Oh I missed adding a .* after the group:

Code:
$> 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:
Code:
awk '/trc.$/{sub(/.$/,"",$NF); print $NF}' infile
/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

 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

filter parts of a big file using awk or sed script

I need an assistance in file generation using awk, sed or anything... I have a big file that i need to filter desired parts only. The objective is to select (and print) the report # having the string "apple" on 2 consecutive lines in every report. Please note that the "apple" line has a HEX... (1 Reply)
Discussion started by: apalex
1 Replies

2. Shell Programming and Scripting

Urgent! Sed/Awk Filter Find Pattern Delete Till End Of Line

Hi, I need help with using an awk or sed filter on the below line ALTER TABLE "ACCOUNT" ADD CONSTRAINT "ACCOUNT_PK" PRIMARY KEY ("ACCT_ID") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "WMC_DATA" LOGGING ENABLE Look for... (2 Replies)
Discussion started by: rajan_san
2 Replies

3. Shell Programming and Scripting

Use of awk/sed to filter out fdisk output

Hi , I am trying to filter out the below output of fdisk -l command : fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 ... (9 Replies)
Discussion started by: omkar.jadhav
9 Replies

4. Shell Programming and Scripting

Use of awk or sed to filter out the ouput

Hi, i am trying to get the system model with the help of awk : $ prtconf | awk '/^System Model/' System Model: IBM,8408-E8D but i want just the below outout that is command should chk for pattern <IBM,> and remove it from the final output : System Model:8408-E8D Can... (2 Replies)
Discussion started by: omkar.jadhav
2 Replies

5. Shell Programming and Scripting

Complex Filter using grep, awk or sed

Hi, I'm not very familiar witrh sed or awk and hope the somebody can help me to solve my problem. I need to filter a text report using grep, sed or awk. I would like to cut out text lines with the pattern INFO and if exists the following lines of the pattern DETAILS. I need te keep the lines with... (4 Replies)
Discussion started by: Frankg
4 Replies

6. Shell Programming and Scripting

Awk/sed/cut to filter out records from a file based on criteria

I have two files and would need to filter out records based on certain criteria, these column are of variable lengths, but the lengths are uniform throughout all the records of the file. I have shown a sample of three records below. Line 1-9 is the item number "0227546_1" in the case of the first... (15 Replies)
Discussion started by: MIA651
15 Replies

7. Shell Programming and Scripting

awk or sed or grep filter a line and/or between strings

Hi, I have multiple files on a directory with the following content: blahblah blahblah hostname server1 blahblah blahblah ---BEGIN--- aaa bbb ccc ddd ---END--- blahblah blahblah blahblah I would like to filter all the files with awk or sed or something else so I can get below... (6 Replies)
Discussion started by: bayupw
6 Replies
GREP(1) 						      General Commands Manual							   GREP(1)

NAME
grep - search a file for lines containing a given pattern SYNOPSIS
grep [-elnsv] pattern [file] ... OPTIONS
-e -e pattern is the same as pattern -c Print a count of lines matched -i Ignore case -l Print file names, no lines -n Print line numbers -s Status only, no printed output -v Select lines that do not match EXAMPLES
grep mouse file # Find lines in file containing mouse grep [0-9] file # Print lines containing a digit DESCRIPTION
Grep searches one or more files (by default, stdin) and selects out all the lines that match the pattern. All the regular expressions accepted by ed and mined are allowed. In addition, + can be used instead of * to mean 1 or more occurrences, ? can be used to mean 0 or 1 occurrences, and | can be used between two regular expressions to mean either one of them. Parentheses can be used for grouping. If a match is found, exit status 0 is returned. If no match is found, exit status 1 is returned. If an error is detected, exit status 2 is returned. SEE ALSO
cgrep(1), fgrep(1), sed(1), awk(9). GREP(1)
All times are GMT -4. The time now is 12:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy