Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Im a linux newbie and Im trying to create a very basic script that will echo a question like "What is your name?" but i would like for the question not to echo the whole sentence at once but word by word or even character by character, in other words to give the illusion that the computer is actually typing the question.I hope this makes sense. I played around with the sleep command, but it will echo each word in a different line rather than the same line. Is there a way to do this? Thank
- RRR
Last edited by RavhisingRickRude; 12-28-2010 at 01:10 AM.
You could do this with an Expect script. There should already an Expect script named "beer.exp" installed on your computer (if Expect is installed) that will show you an example of how to do it.
Try this:
echo -n "Hey"; sleep 1; echo -n " man,"; sleep 1; echo -n " what's"; sleep 1; echo -n ' up?'; sleep 1
all on one line. And try this:
echo -n "H"; sleep .5; echo -n e; sleep .5; echo -n y; sleep .5; echo -n " man,"; sleep 1; echo -n " what's"; sleep 1; echo -n ' up?'
The quotes around " man," and " what's" ensure the punctuation marks aren't enterpreted as something else by bash. And the single quotes around ' up?' negates the ? so bash doesn't interpret it as a built-in variable bash uses in certain cases, like returning error codes. You'll learn neat little things like that as you go along, take the advice of the other posters and read the manual for echo and check out the bash scripting guide suggested by the other post. There are guides you can download for offline reading that you can upload to an ipad or similar document reader. That way when you're on a bus or waiting somewhere you can study it. Bash is not as powerful as a legitimate programming language but it sure is handy for saving you a lot of time on otherwise time consuming, mundane tasks like renaming multiple files, tagging your mp3 files, etc. Have fun.
Last edited by SharpyWarpy; 12-25-2010 at 11:02 PM.
Reason: additional info
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.