Clear specific part of the screen


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Clear specific part of the screen
# 1  
Old 05-04-2013
Clear specific part of the screen

I want to clear specific part of the screen. Say for example , i am running a bash script

Code:
for i in {1..100}
do
echo "Current Record = $i"
done

if i use a clear command over there , it will clear my screen however when i scroll up i would have the old records , is there anyway in unix to just clear a single line everytime
# 2  
Old 05-04-2013
Not sure what you want to achieve; if you want to output to a single line only, try adding a <carriage return> character:
Code:
$ for i in {1..10}; do echo -en "\rCurrent Record = $i"; sleep 1; done

This User Gave Thanks to RudiC For This Post:
# 3  
Old 05-04-2013
You could use this function where 'char="lots of spaces as required"', and, vert and horiz are the rows and columns of the terminal window where you want to over _write_...

https://www.unix.com/unix-dummies-que...-function.html

Bazza...
# 4  
Old 05-04-2013
Quote:
Originally Posted by chidori
s there anyway in unix to just clear a single line everytime
You can overwrite the same line every time by printing a carriage return instead of a newline, the cursor will return to the beginning of the line but not travel down to the next line.

Note this does not clear the line per se, you would need to print blank spaces or use an escape sequence.

Code:
printf "Wait for it\r"
sleep 5
printf "Ding!          \r"

Things like setting up a scrolling region inside your terminal will also prevent scrollback but are not compatible with all terminals.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 05-04-2013
Hi.

See also man tput ... cheers, drl
# 6  
Old 05-05-2013
Thanks for your input guys.. This is what i was looking out for Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Byobu specific screen size.

There is away to make a window pane a specific size. I just forgot how to do it. Something like this: Ctrl-A : split-window -l xx -h xx Anyone know the right way to do this? Thanks. (1 Reply)
Discussion started by: ignatius
1 Replies

2. Shell Programming and Scripting

[Solved] Printing a part of the last line of the specific part of a file

Hi, I have 80 large files, from which I want to get a specific value to run a Bash script. Firstly, I want to get the part of a file which contains this: Name =A xxxxxx yyyyyy zzzzzz aaaaaa bbbbbb Value = 57 This is necessary because in a file there are written more lines which... (6 Replies)
Discussion started by: wenclu
6 Replies

3. Shell Programming and Scripting

Clearing part of screen in Korn Shell

Hi, I am writing a menu driven Korn script where I am getting some input from the users (host details, like Hostname, HBA WWN, Devices etc...). I face a challenge when the number of input lines goes past my window size. For this reason, I am planning to use a part of the screen for user input, say... (3 Replies)
Discussion started by: lasko
3 Replies

4. Shell Programming and Scripting

Screen Output to Specific Columns

User with moderate experience: I run a script (my addiction is KSH) that reads a file and reports certain parameters back to the user on screen and also piped to a file. The file(s) I read is/are located under different directories, and is usually called the same thing. Sometimes not. For... (3 Replies)
Discussion started by: Brusimm
3 Replies

5. Shell Programming and Scripting

Clear Screen Command for BASH shell

I am unable to use clear or cls command on bash shell. I have recently installed Cygwin and am using that for practicing unix commands. I see that I can use Ctrl + L to clear the screen. I created an alias in my .bashrc to do the same as alias cls='^L' This is how i defined other aliases ... (4 Replies)
Discussion started by: erora
4 Replies

6. Programming

how to clear screen in GDB session

hi , Could any one tell me the command for clearing the screen in GDB session (1 Reply)
Discussion started by: useless79
1 Replies

7. Shell Programming and Scripting

Clear screen in NAWK

Hello guys, I wonder if it is possible to clear out the screen in AWK. I'm printing out mail messages and I would like every message starting on the beginning of the screen. When I use FOR loop and printf("\n") it clears out the screen but my text is somewhere in the middle of the screen. ... (2 Replies)
Discussion started by: petoSVK
2 Replies

8. Programming

clear screen in g++

How do I clear screen in g++ I've included curses and tried compile with lcurses as per gcc but fails, I can clear by using system("clear") but would prefer to use the curses library if possible. (2 Replies)
Discussion started by: gefa
2 Replies

9. Programming

clear screen

what is the syntax for clearing the screen in c ? when i tried "Clrscr()" the CC complier does not reconise it. please do tell me more about this. thanking you imma (6 Replies)
Discussion started by: immanuelgangte
6 Replies

10. Programming

How to clear screen

I searched the post and someone said to clear the screen in C, use printf("\033[2J"); ?? However, this doesn't work...typo or no. What is an equivalent command to 'CLS' in DOS/'clear' in UNIX to clear the screen and go to top of screen?? Thank you. (2 Replies)
Discussion started by: giannicello
2 Replies
Login or Register to Ask a Question