| Author |
delete row in linux file based on condition
|
jaya kemmannu
Ranch Hand
Joined: Sep 23, 2011
Posts: 72
|
|
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: 372
|
|
|
'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: 2
|
|
|
you can use wild cards (*,?) for this
|
 |
Richard Tookey
Ranch Hand
Joined: Aug 27, 2012
Posts: 372
|
|
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: 14571
|
|
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.
|
 |
 |
|
|
subject: delete row in linux file based on condition
|
|
|