How can I send a keystroke like 'q' to a script that ends with a call to less?
test.sh
ls -l | less If I call test.sh it hangs and waits for the user type 'q'. How can I do something like this:
echo 'q' | test.sh And have the script exit?
21 Answer
You can do this, which still have less page the output, but it will exit when it hits eof.
LESS=-E ./test.sh or
./test.sh | cat which just dumps the output to the screen.