3 ms·
#!/bin/bash echo "Magic!" echo -en "\033[1F\033[2K" echo "Moar Magic!" This script will print "Magic!" then the next echo sends escape sequences that move the
by syn0byte 8y ago
#!/bin/bash
echo "Magic!"
echo -en "\033[1F\033[2K"
echo "Moar Magic!"
This script will print "Magic!" then the next echo sends escape sequences that move the cursor up 1 line with '\033[1F', then '\033[2K' clears the line the cursor is on, which is now the "Magic!" line. Then we output "Moar Magic". 3 commands but only one line of output.
The -e option on echo enables the escape sequences instead of literal chars. -n disables echos automatic newline for the sequence that deletes the first line
scp servers can of course do all the same trickery.