Last active
August 29, 2015 14:12
-
-
Save LeoHuckvale/90477374d99c84cfbfd8 to your computer and use it in GitHub Desktop.
Run a command in shell with stdout and stderr redirected to null
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Run a command with stdout and stderr redirected to null | |
# Usage: | |
# $ quiet foo | |
# Check command is valid | |
command -v $1 >/dev/null 2>&1 || { echo >&2 "$1: command not found"; exit 1; } | |
# Run command with all arguments | |
$@ >/dev/null 2>&1 |
This doesn't work with filenames with spaces, e.g.:
$ quiet evince some\ filename\ with\ spaces.pdf &
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation: