struct

(** Expand a file expression (with meta-characters) into the list of existing files. The optional parameter null refers to the nullglob bash option. By default null=false.

# Files.glob "/etc/*tab";;
  : string list = ["/etc/crontab"; "/etc/fstab"; "/etc/inittab"; "/etc/mtab"]
*)

let glob ?(null=false) (args:filexpr) = 
  let shopt = ("shopt "^(if null then "-s" else "-u")^" nullglob\n"in
  let cmd = shopt^"for i in \"$@\"; do echo $i; done" in
  make ~at:Treat.identity ~ot:String.Text.of_string cmd ~script:true ~args:(Some args) ();;

(** The following functions are wrappers of the homonymous unix command. The difference from the Shell versions is that they ignore their input and take a filexpr as unique argument. *)



(** Wrapper for the cat unix filter. Examples:
# wc (Files.cat "/etc/*tab");;
  : int = 1418

# wc (Files.cat ~opt:"-n" "/etc/*tab");;
  : int = 1691
*)

 let cat ?(opt="") (arg:filexpr) =
  make ~at:Treat.identity ~ot:String.Text.of_string "cat" ~opt ~args:(Some arg) ();;

 let cut  ?(opt="") (arg:filexpr) = 
   make ~at:Treat.identity ~ot:String.Text.of_string "cut" ~opt ~args:(Some arg) ();;

 let head ?(opt="") (arg:filexpr) = 
  make ~at:Treat.identity ~ot:String.Text.of_string "head" ~opt ~args:(Some arg) ();;

 let nl ?(opt="") (arg:filexpr) = 
  make ~at:Treat.identity ~ot:String.Text.of_string "nl" ~opt ~args:(Some arg) ();;

 let sort ?(opt="") (arg:filexpr) = 
  make ~at:Treat.identity ~ot:String.Text.of_string "sort" ~opt ~args:(Some arg) ();;

 let tac  ?(opt="") (arg:filexpr) = 
  make ~at:Treat.identity ~ot:String.Text.of_string "tac" ~opt ~args:(Some arg) ();;

 let tail ?(opt="") (arg:filexpr) = 
  make ~at:Treat.identity ~ot:String.Text.of_string "tail" ~opt ~args:(Some arg) ();;

 let uniq ?(opt="") (arg:filexpr) = 
  make ~at:Treat.identity ~ot:String.Text.of_string "uniq" ~opt ~args:(Some arg) ();;


end