A: 

use grep -L (print none matching lines)

Sorry - thought you just wanted lines without 0,000 at the end

Martin Beckett
grep -L will print non-matching filenames.grep -v would print non-matching lines, but the OP seems to be after something more complicated (using ranges).
mopoke
Ok I thought they just wanted to print anyting without 0.000 at the end
Martin Beckett
Indeed, my example was a bit misleading – there are other faulty values besides 0, e.g. negative ones.
Florian Jenn
+3  A: 

Have a look at sed:

sed '/start_pat/,/end_pat/d'

will delete lines between start_pat and end_pat (inclusive).

To delete multiple such pairs, you can combine them with multiple -e options:

sed -e '/s1/,/e1/d' -e '/s2/,/e2/d' -e '/s3/,/e3/d' ...
Alok
Great! I knew I was missing something… I always used sed with single patterns and never recalled that it offers ranges.
Florian Jenn
Also, I can put the expressions in a file, where I can also use comments (with `#`). The command line then is `sed -f scriptfile <infile >outfile`.
Florian Jenn
A: 

Firstly, why do you need to keep a record of what you have done? Why not keep a backup of the original file, or take a diff between the old & new files, or put it under source control?

For the actual changes I suggest using Vim.

The Vim :global command (abbreviated to :g) can be used to run :ex commands on lines that match a regex. This is in many ways more powerful than awk since the commands can then refer to ranges relative to the matching line, plus you have the full text processing power of Vim at your disposal.

For example, this will do something close to what you want (untested, so caveat emptor):

:g!/^\d\d\.\d\d\.\d\d\d\d/ -1 write tmp.txt >> | delete

This matches lines that do NOT start with a date (the ! negates the match), appends the previous line to the file tmp.txt, then deletes the current line.

You will probably end up with duplicate lines in tmp.txt, but they can be removed by running the file through uniq.

Dave Kirby
I'd like to keep short notes about the records I threw out and why. I will work with these data not very frequently, and I know I might forget what I had done.Also, someone else may need to understand and reproduce what I've done.Sadly, your vi/ex example doesn't really solve my problem, because all lines start with a date. But I understand the direction you're pointing to.
Florian Jenn
A: 

you are also use awk

awk '/start/,/end/' file
ghostdog74
A: 

I would seriously suggest learning the basics of perl (i.e. not the OO stuff). It will repay you in bucket-loads.

It is fast and simple to write a bit of perl to do this (and many other such tasks) once you have grasped the fundamentals, which if you are used to using awk, sed, grep etc are pretty simple.

You won't have to remember how to use lots of different tools and where you would previously have used multiple tools piped together to solve a problem, you can just use a single perl script (usually much faster to execute).

And, perl is installed on virtually every unix/linux distro now.

(that sed is neat though :-)

DaveC