Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 02-25-2009, 02:51 AM   #1
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Rep: Reputation: 30
Grep help needed

Hi all,

I need some help to grep . I have lines inside a file as follows.

red       1m,2s,300ms
blue      5s,700ms
green     129ms
yellow    4m,200ms
rose      58s

I want to remove the lines which has minutes in the second column , like 1m and 4m.How to do that with grep or awk or sed?

Old 02-25-2009, 04:08 PM   #2
Registered: Oct 2007
Distribution: Fedora, openSUSE
Posts: 252

Rep: Reputation: 39
Why do you need to do that? There are various ways to do it, but it smells a little like homework?

You could use grep -o and look for everything up to the first space, or use sed to cut out everything from the first space onwards. The man/info pages tell you everything you need.
Old 03-03-2009, 05:37 PM   #3
Registered: Jul 2007
Location: Germany
Distribution: Debian, Gentoo, Mac OS X
Posts: 137

Rep: Reputation: 22
You can remove lines that match with grep -v. If you want something more precise, i.e., specify the second column, you need awk(1), then good luck.

grep -v "[0-9]m," <filename>

Last edited by synss; 03-03-2009 at 05:41 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 11:31 PM
Help needed in grep for .tar.gz ZAMO Linux - General 2 07-28-2008 12:45 PM
Bash loop using output of grep not working as needed Jim Pye Programming 7 01-16-2008 11:27 PM
grep option needed ziox Linux - General 7 01-05-2005 12:02 AM
Grep help needed Dirt Linux - Newbie 4 08-03-2003 06:49 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:18 AM.

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