I want to pipe the output of one command to another script. In this other script I want to check whether the input was empty or just consists of spaces. If this is the case, I'll ignore it. Otherwise, I want all the input to be forwarded to another few commands.For more clarity, I'll run something like cat input.txt | ./script.sh where input.txt looks like line 1line 2line 3and script.sh currently looks like:read input_textif [ -z $input_text ]    # ignore emtpy input    then exit 0else    # do something here with the inputfiThe problem is that in this scenario, the first line of the input line 1 is read into the input_text variable and therefore not forwarded with the rest of the input (which then solely consists of lines 2 and 3) into the code following after else.So, how can I first check whether the input consists of more than just empty spaces and then forward the whole input to another command?
Check piped input on empty spaces and forward it
bash;shell;shell script
That would mean you want to forward the input as soon as you see a non-blank character.awk -v cmd='otherCommand' '  forward {print | cmd; next}  {initial_output = initial_output $0 \n}  NF {printf %s, initial_output | cmd; forward = 1}'Example:$printf '%b\n' ' ' '' '\t' | awk -v cmd='echo START; sed s/.*/<&>/' '  forward {print | cmd; next}  {initial_output = initial_output $0 \n}  NF {printf %s, initial_output | cmd; forward = 1}'$printf '%b\n' ' ' '' '\t' something | awk -v cmd='echo START; sed s/.*/<&>/' '  forward {print | cmd; next}  {initial_output = initial_output $0 \n}  NF {printf %s, initial_output | cmd; forward = 1}'START< ><><       ><something>