Shell Scripts, Aliases, Functions

  • Command lines too long or clumsy? You could make a menu entry in your window manager, or you could write:
    • Shell script: a file with commands, just like you'd type at a shell prompt. Works in all shells.
      #!/bin/sh
      grep something "$@" | pr | lpr

      "$@" will expand into any filename(s) you give
    • Bourne-type shell function: a list of commands, like a shell script.
      grepper() {
         grep something "$@" | pr | lpr
      }

      "$@" will expand into any filename(s)
    • C-type shell alias: condenses a command line into a one-word abbreviation.
      alias grepper 'grep something \!* | pr | lpr'

      \!* will expand into any filename(s)
  • Execute any of those like this:
    grepper file*
< previous  index  next >

Contact Jerry Peek