Executables

In addition to using built-in operators, you can, of course, call any executable. Pipelines may contain a mixture of marcel operators and host executables. Piping between operators and executables is done via streams of strings.

 

For example, this command combines operators and executables, and lists the usernames of users whose shell is /bin/bash. map and select are marcel operators, while cat, xargs and echo are Linux executables.

cat /etc/passwd \

| map (line: line.split(':')) \

| select (*line: line[-1] == '/bin/bash') \

| map (*line: line[0]) \

| xargs echo

  • cat /etc/passwd: Obtain the contents of the file. Lines are piped to subsequent commands.

  • map (line: line.split(':')): Split the lines at the : separators, yielding 7-tuples.

  • select (*line: line[-1] == '/bin/bash'): select those lines in which the last field is /bin/bash.

  • map (*line: line[0]): Keep the username field of each input tuple.

  • xargs echo: Combine the incoming usernames into a single line, which is printed to stdout.

  • github
  • Twitter
  • email