Newbie needs help with script
Hello Everyone,
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 |
Code:
echo -n Code:
man command Code:
man -k keyword HTH |
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. |
How about:
Code:
#!/bin/bash |
Or:
Code:
line="What is your name?" |
All times are GMT -5. The time now is 03:24 PM. |