I've got a unix command sequence that goes something like:
command1 | command2 | command3 | wc -l
Now that I have the number of lines, I'd like to do something (run a specific command with no inputs) if the number of lines isn't equal to a specific number. My shell scripting is fantastically rusty (perhaps 10 years or more since I've done much Unix work) so I don't know how to add this kind of conditional to a command sequence. Does anyone know?
You need to capture the output of your
wc
command and useif
to run another command if it's not equal to the number of lines you want, such as:Kinda ugly .. but this works.
nothing's
echo
ed in the second case