Skip to content

Instantly share code, notes, and snippets.

@abdennour
Created October 4, 2019 07:58
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 abdennour/78e1f8ada01cd85e77d06bec9aa8f201 to your computer and use it in GitHub Desktop.
Save abdennour/78e1f8ada01cd85e77d06bec9aa8f201 to your computer and use it in GitHub Desktop.
Bash script reads from pipe, stdin < or first argument
#!/bin/bash
# Available SYNTAX:
# --- $0 /path/file
# --- $0 < /path/file
# --- echo "my content" | $0
# either comes from first argument or from /dev/stdin.
content_to_replace="${1:-/dev/stdin}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment