Getting the cursor position

I need to get the cursor position, and put it inside a variable. Problem is, i don't have the tput command, or ncurses.

Apparently I was supposed to try the following:

echo -e '\E[6n'

But I don't get a value or anything. Please help.

Try this:

echo -e '\033[6n' ; read -sd R CURPOS
CURPOS=${CURPOS#*[}

That doesn't work for some reason. Is there another way?

Which escape sequence actually works depends on the terminal (and the terminal emulation) you use. Alas, the times where knowing the terminal type was a matter of issuing "echo $TERM" are long gone: most of the wonderful replacements of "xterm" desktop systems like GNOME or KDE are pestering us with their own replacements which claim to be "xterm"s when in fact they aren't - only compatible up to a certain point.

So make sure you are really working with the terminal you believe to work with and maybe re-read the termcap sequences of the one really used.

I hope this helps.

bakunin