Skip to content

Instantly share code, notes, and snippets.

@guumaster
Created March 8, 2013 23:56
Show Gist options
  • Save guumaster/5121459 to your computer and use it in GitHub Desktop.
Save guumaster/5121459 to your computer and use it in GitHub Desktop.
Deteccion de tipo de entrada/salida en ficheros bash
#!/bin/bash
if [[ -p /dev/stdin ]]
then
echo "stdin is coming from a pipe"
fi
if [[ -t 0 ]]
then
echo "stdin is coming from the terminal"
fi
if [[ ! -t 0 && ! -p /dev/stdin ]]
then
echo "stdin is redirected"
fi
read
echo $REPLY
#!/bin/bash
if [[ -t 1 ]]; then
echo "stdout is a terminal".
else
echo "stdout is NOT a terminal".
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment