1,105,546 Community Members

How get the Cursor Position

Member Avatar
Newbie Poster
3 posts since Jun 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

Dear All,

I have just started, playing with unix shell programming.
I am in need to know, that how to get the position of cursor at unix shell.

To set the cursor position i am using command
# tput cup x y

Member Avatar
jim mcnamara
Junior Poster
179 posts since May 2004
Reputation Points: 19 [?]
Q&As Helped to Solve: 10 [?]
Skill Endorsements: 0 [?]

shell programming and C/C++ are not the same thing. maybe a moderator will move your post for you.

Anyway, in shell there is no way without writing code (the ncurses library provides calls to do this) without resorting to C/C++ code. Plus you have to be in graphics mode....

see for someone with the same probleem.:

Member Avatar
Newbie Poster
1 post since Jan 2012
Reputation Points: -3 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

In case anybody is still looking for this .

function ReceiveCmd {
		local Reply=""
		while IFS= read -srN1 ; do 
			 [ "${REPLY}" != "${1}" ] || break
	function GetCurPos {
		echo -n $'\e[6n' ; ReceiveCmd R
		IFS=';' REPLY=( ${REPLY:2} )
echo ${REPLY[@]}
This article has been dead for over three months: Start a new discussion instead
Start New Discussion
Tags Related to this Article