Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Going backwards in a bash prompt

Tags:

bash

prompt

I'd like to have a blank line after my bash prompt and before the output on my Mac. It should look like this would:

echo; ls

Can I add a newline to my bash prompt and then go back up one line to wait for user input? Is there something obvious I'm missing?

like image 752
JPLemme Avatar asked Nov 10 '08 16:11

JPLemme


People also ask

How do I go back in bash?

You can go back to the parent directory of any current directory by using the command cd .. , as the full path of the current working directory is understood by Bash . You can also go back to your home directory (e.g. /users/jpalomino ) at any time using the command cd ~ (the character known as the tilde).

What does \r do in bash?

The -r tests if the file exists and if you have read permission on the file. Bash scripting tutorial - if statement. The meaning of -r depends on what program/command it is given as an argument for. In this case it is for [ , and means to check whether the file named by the next argument is readable.

What does $() mean in bash?

Example of command substitution using $() in Linux: Again, $() is a command substitution which means that it “reassigns the output of a command or even multiple commands; it literally plugs the command output into another context” (Source).

Which of the following operators will reverse the sense of a test or exit status in Linux?

The ! operator inverts the exit status of the command to which it is applied (see Example 6-2). It also inverts the meaning of a test operator.


1 Answers

I know this is old but for someone like me who came across this while googling for it. This is how you do this... It's actually pretty simple!

Check out this link --> Cursor Movement

Basically to move up N number of lines:

echo -e "\033[<N>A HELLO WORLD\n"

Just change the "< N >" to however many lines you want to go back... For instance, to move up 5 lines it would be "/033[5A"

like image 99
Matt Avatar answered Sep 21 '22 20:09

Matt