I'm using the escape sequence \u001B[6n
to find the current terminal cursor location in linux. However, when I run the command echo -e '\u001B[6n'
, the response is seemingly written as input to the terminal?
I'm trying to use this command from another process and so I need the result written to stdout directly. The below example of echo -e '\u001B[6n' ; read -d R
therefore might seem fine in the console but does not work in practice.
Why is the response (at least seemingly) written to the input line of the terminal? Does echo yield this behaviour and if so why?
Is there a way to have the result from the echo printed "as usual" (to stdout), or is there another way (command) to retrieve the cursor location?
EDIT
As this question got flagged as a duplicate of this question, I would like to highlight
- the explicit requirement of avoiding the command
read
- The question as to why the output of
echo -e
(as well asprintf
) end up on the input line in the terminal