This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

delete row in linux file based on condition

 
jaya kemmannu
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use wild cards (*,?) for this
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18276
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic