OCaml is a weird teaching choice for broad Unix programming, but it makes more sense than bash once the code stops being toy-sized and starts touching files, processes, and error paths in more than one place. Shell scripts let typos turn into state changes, and C gives you the usual memory footguns.
That snippet is ugly. Cleaner OCaml is easier to maintain than the average bash blob if you care more about finding mistakes before prod than saving ten minutes on ML syntax.