smh

A string manipulation tool written in haskell.


smh aims to bring the power of optics into the command line. It provides a terse, domain specific language for various string manipulation tasks.


Examples of usage

  • smh 'words.if > len 3|get' < input_file - display all words longer than 3 characters
  • smh 'words.[0]|over upper' "hello world" - capitalize all words
  • smh 'lines.if startsWith "*".%words.[2]|get' < input_file - display the third word in lines that start with an asterisk
  • smh 'atKey "b"|over to %el.sum' '{"a": 1, "b": [1, 2, 3, 4, 5]}' - sum the values of a JSON array at the "b" key of a JSON object
  • '%(words.if isNumber)|get' < input_file - get all numbers in a file

Visit the getting started page or the user guide for more details and examples.