Skip to content

Instantly share code, notes, and snippets.

@OnorioCatenacci
Created October 24, 2011 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save OnorioCatenacci/1308161 to your computer and use it in GitHub Desktop.
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
(*
* 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