Created
October 24, 2011 01:19
-
-
Save OnorioCatenacci/1308161 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 (args:string[]) = | |
let source_file = args.[1] | |
let target_file = args.[2] | |
let t_strings = File.ReadAllLines(source_file) |> Array.filter (fun cl -> cl.StartsWith "Unit Disposition") | |
File.WriteAllLines(target_file,t_strings) | |
0 | |
main fsi.CommandLineArgs;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment