Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ifif/elseelse/fifi works. Assuming bash or zshany Bourne-like shell:
if
else
fi
cmd1 < input.txt | cmd2 | if [[[ -n $DEFINED"$DEFINED" ]];]; then cmd3; else cat; fi | cmd4 | cmd5 | cmd6 | (...) | cmdN > result.txt
if/else/fi works. Assuming bash or zsh:
cmd1 < input.txt | cmd2 | if [[ -n $DEFINED ]]; then cmd3; else cat; fi | cmd4 | cmd5 | cmd6 | (...) | cmdN > result.txt
if/else/fi works. Assuming any Bourne-like shell:
cmd1 < input.txt | cmd2 | if [ -n "$DEFINED" ]; then cmd3; else cat; fi | cmd4 | cmd5 | cmd6 | (...) | cmdN > result.txt
cmd1 < input.txt |\| cmd2 |\| if [[ -n $DEFINED ]]; then cmd3; else cat; fi |\| cmd4 |\| cmd5 |\| cmd6 |\| (...) |\| cmdN > result.txt
cmd1 < input.txt |\ cmd2 |\ if [[ -n $DEFINED ]]; then cmd3; else cat; fi |\ cmd4 |\ cmd5 |\ cmd6 |\ (...) |\ cmdN > result.txt