I need a program that will filter command line input, and strip out CR+LF from any line that has a certain text.
Solution (in C#):
http://www.mrrives.com/Programming/Filter/Filter.cs
And the EXE file:
http://www.mrrives.com/Programming/Filter/Filter.exe
Here is the code (simple):
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Filter { class Filter { static void Main(string[] args) { if (args.Length == 0) { Console.WriteLine("FILTER: Parameter format not correct"); return; } if (args[0] == "/?") { Console.WriteLine("Searches for a text string typed at the prompt or piped from another program"); Console.WriteLine(""); Console.WriteLine("FILTER \"string\""); Console.WriteLine(""); Console.WriteLine("if string in a line, line is echoed without a CR+LF, otherwise it is."); return; } string s = string.Empty; try { while (System.Console.In.Peek() != -1) { s = System.Console.In.ReadLine(); if (s.Contains(args[0])) Console.Write(s); else Console.WriteLine(s); } } catch { } } } }
Note, I was able to use the really nice web site, http://www.manoli.net/csharpformat/format.aspx to format my C# code into HTML