This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Linux / UNIX and the fly likes delete row in linux file based on condition Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "delete row in linux file based on condition" Watch "delete row in linux file based on condition" New topic
Author

delete row in linux file based on condition

jaya kemmannu
Ranch Hand

Joined: Sep 23, 2011
Posts: 87

Hi,

If my input file has below data,I want to delete those rows only in which last column has 2 digits after decimal point. how to write command for this ?

111111|113|MP201205211619451202912|2012-01-12+05:30|2012-01-24+05:30|1255.04
222222|117|OR201205281857441108388|2012-01-05+05:30|2012-01-18+05:30|944.8


Thanks,
Joy
Richard Tookey
Bartender

Joined: Aug 27, 2012
Posts: 1166
    
  17

'cat' the flle and pipe into 'grep' using a regex to select the rows of interest. Direct the result to a new file. I normally use the -P regex option for this sort of filtering.
smitha menon
Greenhorn

Joined: Oct 22, 2012
Posts: 3
you can use wild cards (*,?) for this
Richard Tookey
Bartender

Joined: Aug 27, 2012
Posts: 1166
    
  17

smitha menon wrote:you can use wild cards (*,?) for this


Could you elaborate because I don't see what you are getting at.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17018
    
  26

Richard Tookey wrote:'cat' the flle and pipe into 'grep' using a regex to select the rows of interest. Direct the result to a new file. I normally use the -P regex option for this sort of filtering.


The grep command can do its own "cat"ing. Somnething like:


Expect grief. I always have problems with character escapes on the command line. Never can get the backslash count right.
 
Have you checked out Aspose?
 
subject: delete row in linux file based on condition
 
It's not a secret anymore!