The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to search and replace a particular line in file with sed command sshah1001 UNIX for Dummies Questions & Answers 2 05-30-2009 10:45 PM
Command to search for a file harikamamidala Shell Programming and Scripting 3 07-30-2007 08:04 AM
passwd command search shahnazurs SUN Solaris 5 06-19-2007 07:59 AM
command to search for a wod in a line Srini75 Shell Programming and Scripting 2 06-16-2006 02:44 PM
In Search of a Command radimus UNIX for Dummies Questions & Answers 2 08-10-2001 12:15 PM

Reply
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 06-22-2009
kaushik02018 kaushik02018 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 27
Smile command to search in file

Hi
I want to search in file such that

suppose file A which has keyword # Query_time: 12.080983
Query_time: 5.233292
Query_time: 5.298892

Any command to search top 10 Query_time
  #2 (permalink)  
Old 06-22-2009
Franklin52 Franklin52 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,305
Can you show us the code you have so far, and tell us how it misbehaves?

Regards
  #3 (permalink)  
Old 06-22-2009
kaushik02018 kaushik02018 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 27
Smile

Quote:
Originally Posted by Franklin52 View Post
Can you show us the code you have so far, and tell us how it misbehaves?

Regards
It is slow-log file I have to find highest time taken on the basis of query time

so any command that show top n query time

file is as follow

# Query_time: 2.562404 Lock_time: 0.000018 Rows_sent: 509 Rows_examined: 509
use testanalytics;
SET timestamp=1238053872;
SELECT * FROM `testanalytics`.`anlytcs_mt_dt`;

# Query_time: 12.080983 Lock_time: 0.000034 Rows_sent: 1270 Rows_examined: 2540
SET timestamp=1238116828;
SELECT * FROM `anlytcs_mt_dt`

ORDER BY `anl_evnt_id` DESC;

# User@Host: root[root] @ [10.157.205.10]
# Query_time: 18.391643 Lock_time: 0.000017 Rows_sent: 22296 Rows_examined: 22296
use test_analytics;
SET timestamp=1238455961;
SELECT /*!40001 SQL_NO_CACHE */ * FROM `test_analytics`.`dim_tm`;

# Query_time: 17.690604 Lock_time: 0.000018 Rows_sent: 22296 Rows_examined: 22296
use test_analytics;
SET timestamp=1238461385;
SELECT /*!40001 SQL_NO_CACHE */ * FROM `test_analytics`.`dim_tm`;


any command for result top n Query_time:

Last edited by kaushik02018; 06-22-2009 at 08:47 AM..
  #4 (permalink)  
Old 06-22-2009
pritish.sas pritish.sas is offline
Registered User
  
 

Join Date: Dec 2008
Location: Mumbai
Posts: 44
let me update

Query_time: 2.562404

In this field, is there any space, if space is there , u can cut the exact field through
awk command like awk '{print $field name}' <file>

After that u can get the first 10 Query_time by head command.
  #5 (permalink)  
Old 06-22-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,391
you want it along with the query or only top 10 time??
  #6 (permalink)  
Old 06-22-2009
kaushik02018 kaushik02018 is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 27
Smile

Quote:
Originally Posted by vidyadhar85 View Post
you want it along with the query or only top 10 time??
only top 10 time

---------- Post updated at 06:38 AM ---------- Previous update was at 05:59 AM ----------

Quote:
Originally Posted by kaushik02018 View Post
It is slow-log file I have to find highest time taken on the basis of query time

so any command that show top n query time

file is as follow

# Query_time: 2.562404 Lock_time: 0.000018 Rows_sent: 509 Rows_examined: 509
use testanalytics;
SET timestamp=1238053872;
SELECT * FROM `testanalytics`.`anlytcs_mt_dt`;

# Query_time: 12.080983 Lock_time: 0.000034 Rows_sent: 1270 Rows_examined: 2540
SET timestamp=1238116828;
SELECT * FROM `anlytcs_mt_dt`

ORDER BY `anl_evnt_id` DESC;

# User@Host: root[root] @ [10.157.205.10]
# Query_time: 18.391643 Lock_time: 0.000017 Rows_sent: 22296 Rows_examined: 22296
use test_analytics;
SET timestamp=1238455961;
SELECT /*!40001 SQL_NO_CACHE */ * FROM `test_analytics`.`dim_tm`;

# Query_time: 17.690604 Lock_time: 0.000018 Rows_sent: 22296 Rows_examined: 22296
use test_analytics;
SET timestamp=1238461385;
SELECT /*!40001 SQL_NO_CACHE */ * FROM `test_analytics`.`dim_tm`;


any command for result top n Query_time:
I got command

grep "Query_time" /home/slow-log-new.log | sort -n -k3 -r > /tmp/queries_sorted_by_time &
Reply

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 01:45 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