Find and Remove rows


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find and Remove rows
# 1  
Old 02-21-2012
Find and Remove rows

Code:
*******************************************
* ROW *
*******************************************
CODE:CODE1
FILE: FILE1
FIELD: FIELD1
KEY: KEY1
ORA-00001: unique constraint (ETL.KEY_PK) violated
*******************************************
* ROW *
*******************************************
CODE:CODE2
FILE: FILE2
FIELD: FIELD2
KEY: KEY2
ORA-00001: unique constraint (ETL.KEY_PK) violated


All I need is those 4 rows code,file,filed,key , what it the best way to delete the remaining like ******, *ROW ,
Objective , once I have only those fields, I have use excel and transpose to Columns from rows.
Thanks In Advance,
- S

Last edited by joeyg; 02-21-2012 at 04:31 PM.. Reason: Please wrap examples in CodeTags; not lots of font formatting
# 2  
Old 02-21-2012
What about something like?

Code:
$ cat sample13.txt
*******************************************
* ROW *
*******************************************
CODE:CODE1
FILE: FILE1
FIELD: FIELD1
KEY: KEY1
ORA-00001: unique constraint (ETL.KEY_PK) violated
*******************************************
* ROW *
*******************************************
CODE:CODE2
FILE: FILE2
FIELD: FIELD2
KEY: KEY2
ORA-00001: unique constraint (ETL.KEY_PK) violated

$ cat sample13.txt | grep -v "^*" | grep -v "^ORA"
CODE:CODE1
FILE: FILE1
FIELD: FIELD1
KEY: KEY1
CODE:CODE2
FILE: FILE2
FIELD: FIELD2
KEY: KEY2

This User Gave Thanks to joeyg For This Post:
# 3  
Old 02-22-2012
Through awk..
Code:
awk '!/^(\*|ORA)/' inputfile


Last edited by michaelrozar17; 02-22-2012 at 05:54 AM.. Reason: typo error
# 4  
Old 02-22-2012
Code:
$ awk '!/\*/ && !/ORA/' input.txt
CODE:CODE1
FILE: FILE1
FIELD: FIELD1
KEY: KEY1
CODE:CODE2
FILE: FILE2
FIELD: FIELD2
KEY: KEY2

# 5  
Old 02-22-2012
In sed..
Code:
$ sed -e '/\*/d' -e '/^ORA/d' infile

# 6  
Old 02-27-2012
Thanks everyone for your help,

- S
# 7  
Old 02-27-2012
with sed..

Code:
 sed '/\*\|ORA/d' filename

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to remove matched rows from my file?

Hello, I am new beginner, and just got help from this forum. The command line is :awk '($1, $2) in x { print x print delete x next } { x = $0 }' results>myfileI got a output "myfile" from the orginal file 'results'. The quesion is I don't know how to get all rows... (7 Replies)
Discussion started by: nengcheng
7 Replies

2. Shell Programming and Scripting

Remove rows containing commas with awk

Hello everyone, I have a dataset that looks something like: 1 3 2 2 3 4,5 4 3:9 5 5,9 6 5:6 I need to remove the rows that contain a comma in the second column and I'm not sure how to go about this. Here is an attempt. awk 'BEGIN {FS=" "} { if ($2!==,) print }'Any help is appreciated. (5 Replies)
Discussion started by: Rabu
5 Replies

3. Shell Programming and Scripting

Remove rows with e column values

Hi All, I have a big file with 232 columns and 9 million rows, I want to delete all rows with same column values in col3 through col232. Also the output should be sorted based on first 2 columns. Here is a reduced example with 6 columns. I want to remove rows with duplicate values in col3... (9 Replies)
Discussion started by: alpesh
9 Replies

4. Shell Programming and Scripting

remove consecutive duplicate rows

I have some data that looks like, 1 3300665.mol 3300665 5177008 102.093 2 3300665.mol 3300665 5177008 102.093 3 3294015.mol 3294015 5131552 102.114 4 3294015.mol 3294015 5131552 102.114 5 3293734.mol 3293734 5129625 104.152 6 3293734.mol ... (13 Replies)
Discussion started by: LMHmedchem
13 Replies

5. Shell Programming and Scripting

Remove Blank Rows

Hello All, I am having a problem in automating my UNIX Script to remove the blank spaces in between records. When I incorporate it into my script, the output file is deleting the whole content :confused: Basically this is what I am trying to do: File contains data like this:... (14 Replies)
Discussion started by: Vinsanity
14 Replies

6. Shell Programming and Scripting

Remove comma and next rows beginning from the end

Hello friends, I have a file which consists of many rows, I use a couple of commands to convert it so i can use in a database query for filtering. I need the first columns (msisdns) in a row, seperated with commas, 9855162267,4,5,2010-11-03 17:02:07.627 9594567938f,5,5,2010-11-02... (9 Replies)
Discussion started by: EAGL€
9 Replies

7. Shell Programming and Scripting

Remove 1st two rows and last 2 rows

Hi All, I need to remove 1st 2 line from head and last 2 line from last. I thought it would be possible by using the Head and tail command. But after i am using it is not possible by it. Example:Input file 1 2 3 4 5 Example: Output file 3 But my head and tail command are not... (12 Replies)
Discussion started by: kam786sim
12 Replies

8. UNIX for Dummies Questions & Answers

Remove rows from file

Hi to all,this is my first post here. I've a file as name 89 78 09 67 othername how I can remove the word name and othername from this file, and an eventually blank row in it?Thanks in advance. (2 Replies)
Discussion started by: cv313x
2 Replies

9. UNIX for Dummies Questions & Answers

find and remove rows from file where multi occurrences of character found

I have a '~' delimited file of 6 - 7 million rows. Each row should contain 13 columns delimited by 12 ~'s. Where there are 13 tildes, the row needs to be removed. Each row contains alphanumeric data and occasionally a ~ ends up in a descriptive field and therefore acts as a delimiter, resulting in... (1 Reply)
Discussion started by: kpd
1 Replies

10. Shell Programming and Scripting

remove header and footer rows

I would like to remove some lines from begining of file (header) and some lines from end of file (footer). The header/footer lines generated by web-browser when the user upload a file to my webserver. Example: -----------------------------7d62af20c052c Content-Disposition: form-data;... (2 Replies)
Discussion started by: seaky
2 Replies
Login or Register to Ask a Question