Looking for line processing program

  • Thread starter Thread starter VH
  • Start date Start date
V

VH

The subject line is not very descriptive but what I am looking for is
a program that process a text file and display only those line that
match certain conditions then allow you to add more conditions to
process against these lines.

For example, the program would open a log file, weed out all the lines
except for those that contain "error", then from these get all that
also contain "critical", then display only those that the first
character in the line is not "a".

It would be OK if you have to state all the filter at once but it
would be nicer to process the file progressively as conditions are
added.
 
VH said:
The subject line is not very descriptive but what I am looking for
is a program that process a text file and display only those line
that match certain conditions then allow you to add more
conditions to process against these lines.

For example, the program would open a log file, weed out all the
lines except for those that contain "error", then from these get
all that also contain "critical", then display only those that the
first character in the line is not "a".

It would be OK if you have to state all the filter at once but it
would be nicer to process the file progressively as conditions are
added.

I would probably just use grep, and try something like:

grep file.log error|grep critical|grep -i ^a

You'd have to do it from the command-line, though, and it doesn't
process the file progressively, though, so if those are major issues,
I'm sure there are better solutions. That's just the quick and dirty
one which I would use.
 
VH said:
The subject line is not very descriptive but what I am looking for is
a program that process a text file and display only those line that
match certain conditions then allow you to add more conditions to
process against these lines.

For example, the program would open a log file, weed out all the lines
except for those that contain "error", then from these get all that
also contain "critical", then display only those that the first
character in the line is not "a".

It would be OK if you have to state all the filter at once but it
would be nicer to process the file progressively as conditions are
added.
Get "perl". <http://www.perl.org/>

It was designed for just this sort of problem.

Cheers,
Gary B-)
 
I would probably just use grep, and try something like:

grep file.log error|grep critical|grep -i ^a

You'd have to do it from the command-line, though, and it doesn't
process the file progressively, though, so if those are major issues,
I'm sure there are better solutions. That's just the quick and dirty
one which I would use.

You could also just use the DOS FIND command with piping and/or
redirection to achieve much the same. (Except I don't know how it
could be set to reject lines beginning with "a"; but maybe specifying
the string as "a " [a with trailing space] would do the trick in most
cases?)

To inspect the intermediate files as you go, you'd probably have to
write a small batch file with the required sequence of commands. You
could use MORE within the batch to read the things before invoking the
next step in the series.

To see available options for DOS commands, simply type the command
followed by "/?" at the DOS prompt.
<example>
E:\tmp>find /?
Searches for a text string in a file or files.

FIND [/V] [/C] [/N] [/I] "string" [[drive:][path]filename[ ...]]

/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the
string.
"string" Specifies the text string to find.
[drive:][path]filename
Specifies a file or files to search.

If a pathname is not specified, FIND searches the text typed at the
prompt or piped from another command.
</example>


Cheers, Phred.
 
VH said:
The subject line is not very descriptive but what I am looking for is
a program that process a text file and display only those line that
match certain conditions then allow you to add more conditions to
process against these lines.

For example, the program would open a log file, weed out all the lines
except for those that contain "error", then from these get all that
also contain "critical", then display only those that the first
character in the line is not "a".

It would be OK if you have to state all the filter at once but it
would be nicer to process the file progressively as conditions are
added.

o Columnizer, from Gulf Coastal Software. "Retain/Delete lines per data."

o LineStrip, from Lexacorp. "Drop line if not present."

Both of those, you'd be making a new, modified file. Actually, for what
you've outlined, it would be a sequence of modified files.

These are GUI, but have the mentioned drawback of having to create a
sequence of modified files, to get to where you want. If you do end by
considering Columnizer, let me know. It has a weird interface, and I have
a couple of notes for how to get along with it.
 
The subject line is not very descriptive but what I am looking for is
a program that process a text file and display only those line that
match certain conditions then allow you to add more conditions to
process against these lines.
For example, the program would open a log file, weed out all the lines
except for those that contain "error", then from these get all that
also contain "critical", then display only those that the first
character in the line is not "a".
It would be OK if you have to state all the filter at once but it
would be nicer to process the file progressively as conditions are
added.

DbEdit would do EXACTLY what you want for the first two steps. You
would then need to export to a text file, and then sort, to do the "a"
part :

http://www.arachnoid.com/dbedit/index.html

Just copy the original text to the clipboard and import.

Regards, John.

--
****************************************************
,-._|\ (A.C.F FAQ) http://clients.net2000.com.au/~johnf/faq.html
/ Oz \ John Fitzsimons - Melbourne, Australia.
\_,--.x/ http://www.vicnet.net.au/~johnf/welcome.htm
v http://clients.net2000.com.au/~johnf/
 
I would probably just use grep, and try something like:

grep file.log error|grep critical|grep -i ^a

You'd have to do it from the command-line, though, and it doesn't
process the file progressively, though, so if those are major issues,
I'm sure there are better solutions. That's just the quick and dirty
one which I would use.

You are on the right track. I am currently using BareGrep but looking
for something better. What I am looking for a graphical grep with a
little awk thrown in.

I guess I need something with a little more text processing power.
Let me give another example. Display all the line in the file
containing the word "error" and in those line delete everything after
the first 2 words up to the word "error" then delete everything except
the first word after the word "error" to the end of the line.

The program would progressively prune the file down to only the
relevant data.
 
o Columnizer, from Gulf Coastal Software. "Retain/Delete lines per data."

o LineStrip, from Lexacorp. "Drop line if not present."
LineStrip sound good. Downloaded both. Will play with them.
 
On Thu, 01 Apr 2004 22:44:12 -0600, VH wrote:

[much snipped]
LineStrip sound good. Downloaded both. Will play with them.

You may find some additional candidates here:

http://www.tinyapps.org/text.html

Scroll about halfway down the page to "Text Search, Replace, etc.". Text
Harvest, Catview, and WanyWord might do some of what you want.

Much of what you want to do can be accomplished by chaining command line
filters. At the Windows XP command prompt, this line:

find /i "string1" filename | find /i "string2" | sort

will produce output consisting only of those lines containing both
"string1" and "string2", sorted alphabetically so you can easily remove all
lines beginning with "a".

And if you issued the above command from the "DOS Command to Window" dialog
in Programmer's File Editor
(http://www.simtel.net/product.php?url_fb_product_page=11983), the output
would be captured by the editor, and you could easily set up a macro to
slice and dice each line.
 
Back
Top