ifne
runs a command only if there is input
TLDR
Run command if input
$ command1 | ifne command2
Delete file if results$ find . -empty | ifne xargs rm
Invert condition$ command | ifne -n echo "no output"
Mail if errors$ make 2>&1 | ifne mail -s "errors" [admin]
SYNOPSIS
ifne [options] command [args]
DESCRIPTION
ifne runs a command only if there is input. It reads stdin and passes it to the command if non-empty.
The tool is useful in pipelines where subsequent commands should only run when there's data. The -n flag inverts the behavior.
PARAMETERS
COMMAND
Command to run.ARGS
Command arguments.-n
Run if NO input.--help
Display help information.
CAVEATS
Part of moreutils. Buffers input. Stdin passed to command.
HISTORY
ifne is part of moreutils, a collection of Unix tools by Joey Hess.
