Results 1 to 10 of 11
echo "line 1"
echo "line 2'
[output]
line 1
line 2
Question: Can i move to line 1 and change '1' to '3' without damaging the line 2?...
- 12-06-2008 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 37
Can I move to a previous line in shell script?
echo "line 1"
echo "line 2'
[output]
line 1
line 2
Question: Can i move to line 1 and change '1' to '3' without damaging the line 2?
- 12-06-2008 #2
Is this a question about how to use a specific text editor ?
Men occasionally stumble over the truth,
but most of them pick themselves up
and hurry off as if nothing had happened.
Winston Churchill
... then the Unix-Gods created "man" ...
- 12-06-2008 #3Just Joined!
- Join Date
- Nov 2008
- Posts
- 37
I want to print in the line 1 again without damaging line 2 in a shell script in console or terminal
- 12-06-2008 #4
Interesting question. I wouldn't know. Usually I clear the screen and start anew. It works.
Something like this:
Code:VAR1="1" VAR2="2" ShowOutput () { clear cat << EOF $VAR1 $VAR2 EOF } SimpleLoop () { while true ; do echo -n "What do you want as first variable? " read -n 1 VAR1 ShowOutput done } SimpleLoopCan't tell an OS by it's GUI
- 12-06-2008 #5Just Joined!
- Join Date
- Nov 2008
- Posts
- 37
Very nice.... thanks...
But this is not im looking for...
Consider a wave motion starting in first line and moving to second line and again first line and again second line like wise...........
example:
\ /\ /\
V V
Like this wave motion... starting from first line and going to second and then move to first line again and again second, first etc..etc.........
I Think i can make this with your method but im not sure about it, i want to spend little time with it to be conformed. And also i want to know that whether is there any command or simple method to move to the previous line
thanks for your reply.......
- 12-06-2008 #6Just Joined!
- Join Date
- Nov 2008
- Posts
- 37
Very nice.... thanks...
But this is not im looking for...
Consider a wave motion starting in first line and moving to second line and again first line and again second line like wise...........
example:
Like this wave motion... starting from first line and going to second and then move to first line again and again second, first etc..etc.........
I Think i can make this with your method but im not sure about it, i want to spend little time with it to be conformed. And also i want to know that whether is there any command or simple method to move to the previous line
thanks for your reply.......
- 12-06-2008 #7Just Joined!
- Join Date
- Nov 2008
- Posts
- 37
Can you please tell me the role of `cat << EOF and EOF here, I dont know what they are and why they are used for.
- 12-06-2008 #8When you want to output multiple lines, the cat OEF combo gives a cleaner look in the script and is easier when you want to insert lines, that's all. You could also put 'echo' on every line. It's the same.
Originally Posted by sky_knight02
As for what you want, well it's possible. Is it a repeating patern or a progressive pattern?
Repeating is very easy, just alternate between two different values in the variable.
If you want a progressive pattern, sort of like a character moving, then you need to put some effort in structuring it (hint: it's all about counting)
This will get you a moving X in a row of x's. Not particularly useful I'm afraid. But it is how I would get movement in a standard bash script output.Code:#!/bin/bash opt="x" alt="0" var="0" while [ "$alt" -le "11" ] ; do while [ "$var" -le "10" ] ; do var=`expr $var + 1` if [ "$alt" -eq "$var" ] ; then opt="X" else opt="x" fi echo -n $opt done var="0" alt=`expr $alt + 1` sleep 0.2 clear done
If you make it too big, then refresh rate gets a problem. So if anyone knows the answer to your original question? I bet there are better ways to do this.Can't tell an OS by it's GUI
- 12-07-2008 #9Just Joined!
- Join Date
- Nov 2008
- Posts
- 37
Thanks Freston.... this helped me a lot... ill let you know when i find it....
I hope some one will reply with the right answer.....
- 12-07-2008 #10Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
It sounds like you want to move the cursor.
One way to move the cursor around is to use tput. See Discover tput or Google for tput topics ... cheers, drlWelcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )


Reply With Quote
