Skip to content

Instantly share code, notes, and snippets.

@matlinuxer2
Created June 13, 2012 16:07
Show Gist options
  • Save matlinuxer2/2925005 to your computer and use it in GitHub Desktop.
Save matlinuxer2/2925005 to your computer and use it in GitHub Desktop.
embed python into shell script as a pipe function
#!/usr/bin/env bash
function pipe_in_python() {
python -c "$(cat <<EOPY
import sys
for line in sys.stdin:
print line.replace( 'asdf', 'ASDF' ),
EOPY
)"
}
echo "asdf.asdf.asdf.e" | pipe_in_python | cut -c5-15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment