Excluding the unwanted rows


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Excluding the unwanted rows
# 1  
Old 02-03-2016
Excluding the unwanted rows

Code:
#
Total
Table name 
-----------------------+--------+--------------------------------+--------------------------+---------------
GK_AMP
GK_AMP
GK_AMP
GK_AMP
GK_AMP
GK_AMP
(6


how can i extract only table name excluding other lines ?pls suggest
# 2  
Old 02-03-2016
Hello rocking77,

Could you please try one of the following and let me know if this helps you.
Code:
sed -n '/Table name/p'  Input_file
OR
awk '/Table name/'  Input_file
OR
grep -i "Table name"  Input_file

Thanks,
R. Singh
# 3  
Old 02-03-2016
Quote:
Originally Posted by rocking77
how can i extract only table name excluding other lines ?pls suggest
If you tell us how to differentiate that row from the others, we might become able to help.
Is it
- the row containing "Table name"?
- the third row?
- the row after the "Total" row?
- the row before the one starting with "----"?
- other?
# 4  
Old 02-03-2016
Rudi ,

I m trying to fetch the content from column (Tablename).

Let me refine my requirement .

below is query result.
Code:
# Of Versioned Tables         6
     Total # Of Versions      12

       Database        | Schema |           Table Name           |   
-----------------------+--------+--------------------------------+---
 GK_AMP             | ADMIN  | AGG_BUS_PRO_JAN
 GK_AMP          | ADMIN  | AGG_BUS_PRO_MTD
 GK_AMP          | ADMIN  | AGG_BUS_PRO_QTD
 GK_AMP          | ADMIN  | AGG_BUS_PRO_R12
 GK_AMP          | ADMIN  | AGG_BUS_PRO_YTD
 GK_AMP          | ADMIN  | AGG_BUS_PRO_YTD
(6 rows)

Out of that result i am trying to write another SQL like ..


XXXXX $Database . $ Table Name for n number of rows under columns Database & Table Name

Last edited by rocking77; 02-03-2016 at 11:35 AM..
# 5  
Old 02-03-2016
That doesn't really answer my question: "HOW to unambigiously identify the target row?".

OK, let's assume it's the one above the --+--+-- line, try
Code:
awk  '/^[-+]+$/ {print LAST} {LAST = $1}' file
Database

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Moving or copying first rows and last rows into another file

Hi I would like to move the first 1000 rows of my file into an output file and then move the last 1000 rows into another output file. Any help would be great Thanks (6 Replies)
Discussion started by: kylle345
6 Replies

2. UNIX for Dummies Questions & Answers

merging rows into new file based on rows and first column

I have 2 files, file01= 7 columns, row unknown (but few) file02= 7 columns, row unknown (but many) now I want to create an output with the first field that is shared in both of them and then subtract the results from the rest of the fields and print there e.g. file 01 James|0|50|25|10|50|30... (1 Reply)
Discussion started by: A-V
1 Replies

3. Shell Programming and Scripting

get rid of unwanted lines

Hi , My output contains the below contents When i execute df -h | grep / | grep -v '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' i get output as below tpshghghg.fgh.com:/vol/scmvol1/scm-vobstore/WebArch.vbs 1.7T 1.3T 452G 74% /vob/WebArch... (6 Replies)
Discussion started by: ptappeta
6 Replies

4. Shell Programming and Scripting

Split single rows to multiple rows ..

Hi pls help me out to short out this problem rm PAB113_011.out rm: PAB113_011.out: override protection 644 (yes/no)? n If i give y it remove the file. But i added the rm command as a part of ksh file and i tried to remove the file. Its not removing and the the file prompting as... (7 Replies)
Discussion started by: sri_aue
7 Replies

5. Shell Programming and Scripting

grep out unwanted lines

Hi, I got a log file and I want to grep out a list of unwanted line which are IP's. Basiclly I want everything ecxept the ip's from my list. If I do a while read line do grep -v $ip_from_my_list logfile done <ip_list it just grep's one IP at a time and repeats. :( Thanks for... (3 Replies)
Discussion started by: stinkefisch
3 Replies

6. Shell Programming and Scripting

Remove unwanted lines

I have a .xml file, where i need some output. The xml file is like: Code: <?******?></ddddd><sssss>234</dfdffsdf><sdhjh>534</dfdfa>......... /Code I need the output like: code 234 534 . . . /code How can i do it? (5 Replies)
Discussion started by: anupdas
5 Replies

7. Shell Programming and Scripting

Deleting specific rows in large files having rows greater than 100000

Hi Guys, I need help in modifying a large text file containing more than 1-2 lakh rows of data using unix commands. I am quite new to the unix language the text file contains data in a pipe delimited format sdfsdfs sdfsdfsd START_ROW sdfsd|sdfsdfsd|sdfsdfasdf|sdfsadf|sdfasdf... (9 Replies)
Discussion started by: manish2009
9 Replies

8. OS X (Apple)

OS/X 10.4 Deleting unwanted applications

What is the correct way to delete unwanted applications from a MACbook running OS/X 10.4.1.1. It is sufficient to drag and drop from Applications folder to Trash, then clear Trash? (2 Replies)
Discussion started by: methyl
2 Replies

9. Shell Programming and Scripting

Filter unwanted lines

Hi All, I have the below input and i only want to filter out some un-wanted info from here. Expected output is below. Can somebody help ? The catch is that i want to grep those lines with term "k=" and lines with term "**" as the 1st column and "07" as the last column. And the number of... (15 Replies)
Discussion started by: Raynon
15 Replies

10. Shell Programming and Scripting

Remove unwanted data?

Hi Can any one help me remove the unwanted data? I would want to remove the complete event id 4910 ( the type there is INFO), that means, I have to remove starting from 7th - 19th lines. can any one of you please help? Thanks, (24 Replies)
Discussion started by: hitmansilentass
24 Replies
Login or Register to Ask a Question