Skip to content

Instantly share code, notes, and snippets.

@jmakeig
Created November 11, 2014 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmakeig/418a6036239ff215bab6 to your computer and use it in GitHub Desktop.
Save jmakeig/418a6036239ff215bab6 to your computer and use it in GitHub Desktop.
Pipe input or get from param
#!/usr/bin/env bash
# From <http://linux.byexamples.com/archives/474/bash-script-that-process-input-from-pipeline-or-file-redirection/>
# If there is not param read from stdin else get from the input
# TODO: Get input from a specific parameter inline or from a file specified in a parameter.
if [ -e $1 ] ;then read str; else str=$1;fi
echo "$str"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment