-
-
Save deneuxj/1309420 to your computer and use it in GitHub Desktop.
A quick and dirty F# Shell Script to filter a text file for all lines which match a certain string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
* Filter a specified file into a second file | |
* Onorio Catenacci | |
* 21 October 2011 | |
*) | |
#r "System.dll" | |
open System.IO | |
//Remember: | |
//When running from the command line, the first argument that isn't the script name is 1 | |
//When running from FSI window, the first argument that isn't the script name is 0 | |
let main = function | |
[| _ ; source_file ; target_file |] -> | |
let t_strings = | |
File.ReadLines(source_file) | |
|> let pred prefix (cl : string) = cl.StartsWith(prefix) in Seq.filter (pred "Unit Disposition") | |
File.WriteAllLines(target_file,t_strings) | |
0 | |
| _ -> | |
eprintfn "Bad arguments" | |
1 | |
main fsi.CommandLineArgs;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment