If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Grep issues

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-13-10, 17:31
urs_77 urs_77 is offline
Member
 
Join Date: Jan 2003
Location: Schaumburg, IL
Posts: 79
Grep issues

I have a file which has the following data:

Direct reads = 32
Direct reads elapsed time (ms) = 23

I am trying to get the values only using the following command:

grep "Direct reads" db_snap1.out | cut -d= -f2

Instead of getting the value from the first Direct reads, I am getting the value from both the rows.

How can I make sure that it will bring back just the data for Direct reads alone?
__________________
Naveen Urs
DBA Manager
IBM Certified Solutions Expert - DB2 LUW V7, V9
Reply With Quote
  #2 (permalink)  
Old 04-13-10, 18:33
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
The command grep "Direct reads" will only keep the lines that contain the text Direct reads. This means it will keep both the lines rather than just the first. I suggest you change your line slightly to something like :

Code:
grep "Direct reads =" db_snap1.out | cut -d= -f2
__________________
Mike
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On