File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 85

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
Ranch Hand

Joined: Aug 27, 2012
Posts: 1084
    
  10

'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
Ranch Hand

Joined: Aug 27, 2012
Posts: 1084
    
  10

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: 16250
    
  21

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.
 
Don't get me started about those stupid light bulbs.
 
subject: delete row in linux file based on condition