LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-03-2008, 09:09 AM   #1
ihickman
LQ Newbie
 
Registered: Feb 2008
Posts: 6

Rep: Reputation: 0
grep help


Hello -- I can't seem to find how to do this.

My grep command: grep ms filename outputs::

<snip>
1207169821905 DC 313ms RC:1000 RID:5 PID:405708 TIMES:289 0 1 0 0 3 0 16 2 0 0 2
1207170392173 DC 301ms RC:1000 RID:5 PID:270582 TIMES:265 0 0 1 0 3 0 23 5 0 0 4
1207170405346 DC 378ms RC:2005 RID:5 PID:376912 TIMES:371 0 0 0 0 3 1 3
<snip>

Question::

How do I narrow my query so it only shows the ###ms so it outputs::

313ms
301ms
378ms

Thanks in advance
 
Old 04-03-2008, 09:23 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
*I* would do... "grep <etc> | cut -f 3"
 
Old 04-03-2008, 09:37 AM   #3
ihickman
LQ Newbie
 
Registered: Feb 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Hey Thanks for the direction Chris;

I needed to specify my 'delimiter' first. But your suggestion defiantly got me on track.

grep ms <file> | cut -d ' ' -f 3
 
Old 04-03-2008, 11:04 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Or something like
Code:
grep -o ...ms filename      # if exactly three digit numbers before ms
grep -o [1-9]*ms filename   # for numbers of any length
 
Old 04-03-2008, 11:09 AM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
ahh, i always forget what the default field seperator is...
 
Old 04-03-2008, 01:42 PM   #6
prad77
Member
 
Registered: Mar 2008
Posts: 101

Rep: Reputation: 15
If the format is kind of same, then

awk { print $3 } filename

Gentoo

Last edited by prad77; 04-17-2008 at 03:39 AM.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to grep multiple filters with grep LinuxLover Linux - Enterprise 1 10-18-2007 07:12 AM
grep output on stdout and grep output to file don't match xnomad Linux - General 3 01-13-2007 04:56 AM
grep: grep for two substrings? eur0dad Linux - General 2 08-17-2006 04:03 PM
bash script with grep and sed: sed getting filenames from grep odysseus.lost Programming 1 07-17-2006 11:36 AM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration