The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
sort data in different columns mogabr Shell Programming and Scripting 15 08-04-2008 07:07 AM
problem in greping the string from file using awk vastare Shell Programming and Scripting 1 04-23-2008 03:40 AM
greping date in a file ali560045 Shell Programming and Scripting 3 02-20-2008 07:30 AM
Help with Data Positioning from Columns in a flat file. oott1 Shell Programming and Scripting 3 06-14-2006 02:22 PM
lining up columns of data pau Shell Programming and Scripting 2 05-16-2006 10:40 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-05-2008
esungoe esungoe is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 6
Question Greping columns data from file.

Hi i am using shell script which perform oracle database query and after that output is redirect to some temporary file.

the output of this file looks like
SQL*Plus: Release 10.2.0.2.0 - Production on Tue Aug 5 16:08:06 2008

Copyright (c) 1982, 2005, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options

SQL>
HOUR COUNT(*)
---------- ----------
11 30
12 12
15 11

SQL> Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining options


Now in fact i want to extract the columns data HOUR and COUNT(*) .Then how can i extract or grep this columns from this temporary file.
any help ..

//regards
sunil
  #2 (permalink)  
Old 08-05-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,333
Something like this should work:


Code:
awk '/HOUR COUNT/{f=1}f' file

Regards
  #3 (permalink)  
Old 08-05-2008
ynilesh's Avatar
ynilesh ynilesh is offline
Registered User
  
 

Join Date: Oct 2007
Location: Bangalore, India.
Posts: 222
Use -B option with grep. like,

To print below 5 lines of search pattern,

Code:
grep -B 5 "HOUR COUNT" filename

It will display,
Quote:
---------- ----------
11 30
12 12
15 11
- nilesh
  #4 (permalink)  
Old 08-05-2008
esungoe esungoe is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 6
in first one when i give below command

#awk '/HOUR COUNT/{f=1}f' <filename>

result::
awk: syntax error near line 1
awk: bailing out near line 1


i dnt know size of column it can be n number in size
for currentr case it is giving me below response.
grep: illegal option -- B
Usage: grep -hblcnsviw pattern file . . .
  #5 (permalink)  
Old 08-05-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,333
Quote:
Originally Posted by esungoe View Post
in first one when i give below command

#awk '/HOUR COUNT/{f=1}f' <filename>

result::
awk: syntax error near line 1
awk: bailing out near line 1
Use nawk or /usr/xpg4/bin/awk on Solaris.

Regards
  #6 (permalink)  
Old 08-05-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Couldn't you just run sqlplus with the -silent option in the first place?
  #7 (permalink)  
Old 08-05-2008
esungoe esungoe is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 6
Great era,
Thanks i was not aware of -silent feature of sqlplus ..

now without greping i got my desire output.

//Regards
Sunil Goyal
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:30 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0