is there a command other than "echo" that can be used to display text to the terminal, in bash?
preferably one that can output to any point in the terminal.
Which command is used as an alternative to echo command? Explanation: printf command is available on most UNIX systems and it behaves much like a substitution for echo command. It supports many of the formats which are used by C's printf function.
Printf provides for the creation of a formatting string and offers a non-zero quit status when it fails. Whereas echo normally leaves with a 0 status and typically outputs inputs headed by the end of line character upon this standard result. The “printf” gives you more options for the output format than the “echo”.
echo command in linux is used to display line of text/string that are passed as an argument . This is a built in command that is mostly used in shell scripts and batch files to output status text to the screen or a file.
cat is for listing contents of any file. echo is for listing value of some variable. Besides, echo without any value is used to insert a new line in many shell scripts. For more subtle and complete difference you can always google.
Maybe tput is what you're looking for. For example you could create a little menu like so:
#!/bin/bash
# clear the screen
tput clear
# Move cursor to screen location X,Y (top left is 0,0)
tput cup 3 15
# Set a foreground colour using ANSI escape. Not sure this works on OSX
tput setaf 3
# Set reverse video mode
tput rev
echo "S U S H I M E N U I T E M S"
tput sgr0
tput cup 5 17
echo "Please select an option"
tput sgr0
tput cup 7 15
echo "1. Sushi Sashimi Combo"
tput cup 8 15
echo "2. Omakase"
tput cup 9 15
echo "3. Chirashi"
tput cup 10 15
echo "4. Eel and Avacado Roll"
# Set bold mode
tput bold
tput cup 12 15
read -p "Enter your choice [1-4] " choice
tput clear
tput sgr0
tput rc
echo "You chose $choice"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With