Go back up a line in a linux console?
问题 I know I can go back the line and overwrite its contents with \r . Now how can I go up into the previous line to change that? Or is there even a way to print to a specific cursor location in the console window? My goal is to create some self-refreshing multiline console app with PHP. 回答1: Use ANSI escape codes to move the cursor. For example: Esc [ 1 F . To put the Escape character in a string you'll need to specify its value numerically, for example "\x1B[1F" As sujoy suggests, you can use