LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   grep help (https://www.linuxquestions.org/questions/linux-newbie-8/grep-help-632716/)

ihickman 04-03-2008 09:09 AM

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

acid_kewpie 04-03-2008 09:23 AM

*I* would do... "grep <etc> | cut -f 3"

ihickman 04-03-2008 09:37 AM

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

colucix 04-03-2008 11:04 AM

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


acid_kewpie 04-03-2008 11:09 AM

ahh, i always forget what the default field seperator is...

prad77 04-03-2008 01:42 PM

If the format is kind of same, then

awk { print $3 } filename

Gentoo


All times are GMT -5. The time now is 05:41 AM.