Using backspace in echo to show process count


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using backspace in echo to show process count
# 1  
Old 06-04-2012
Using backspace in echo to show process count

i have something like this

Code:
 
tablesName="abc def hij akn ... etc etc"
count=0
for i in $tablesName
do
         echo -en "\b\b\b\b\b\b\b\b\b\b\b\b\bTableCount: $count"
         count=`expr $count + 1`
 
done

the above is just a description wha i need is when the loop executes
the output should display
in first cycle TableCount: 1
then in second cycle the above line should be erased and in same place instead of 1 it should display 2.... there shouldnt be any next line characters... all this should be done in same line in output window.
any help id deeply appreciated...
# 2  
Old 06-04-2012
Try:
Code:
count=0
for i in $tablesName
do
  printf "\rTableCount: $((count+=1)) "
  sleep 1
done
echo

This User Gave Thanks to Scrutinizer For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ensuring certain processes do not show up in process table

i've read somewhere a long time ago that there's a way to hide the workings of a script in sub functions so that when run, it doesn't show up in the process table. is this really possible? for instance, i need to run a command that has a password in it. and when that;s being run, it can be... (2 Replies)
Discussion started by: SkySmart
2 Replies

2. Shell Programming and Scripting

Echo backspace in spinner script

Trying to insert a backspace for echo. while true ; do i='-\|/' for j in 1 2 3 4 do echo -ne "$(echo ${i} | cut -c${j})" sleep 1 done done this currently outputs: -\|/-\|/-\|/-\| .....etc ---------- Post updated at 02:34 PM ---------- Previous update was at 02:10 PM... (7 Replies)
Discussion started by: squrcles
7 Replies

3. Shell Programming and Scripting

Show running process command > 60 chars

Hi. I use this command to get list of running process: ps -ef|grep ICP|grep -v grep But how do I set the terminal to show full command? It seems that it always truncated to 60 chars no matter what options I put. e.g output oracle9 25011 24998 0 03:00:05 ? 0:00 /usr/bin/sh... (14 Replies)
Discussion started by: aimy
14 Replies

4. Shell Programming and Scripting

How to show first 0 using seq or +1 count?

Greetings, Using linux based OS and KSH. I m trying to make a simple script to parse some logs to show a count per hour on a specific alarm starting from midnight to the current hour. So I format my "HOUR" variable to show the current time and so I can use it in the following bit of code.... (6 Replies)
Discussion started by: Sekullos
6 Replies

5. Shell Programming and Scripting

compare 2 files and show count same content.

$ cat File1 Non HTTP response code:java.net.ConnectException225073X 000000005143329Load time: 402335410224 Non HTTP response code: ava.net.ConnectException206423X 000000005143330Load time: 402305687161 Non HTTP response code: ava.net.ConnectException290212X 000000005143331Load time:... (1 Reply)
Discussion started by: ooilinlove
1 Replies

6. Shell Programming and Scripting

does the pid of background process show in /proc?

Hi all, I'm reading <advanced bash scripting> and there is a example to kill a background process in a limited time,as shown below: #! /bin/bash #set -n TIMEOUT=$1 count=0 hanging_jobs & { while ((count < TIMEOUT));do eval ' && ((count = TIMEOUT))' ((count++)) sleep 1... (6 Replies)
Discussion started by: homeboy
6 Replies

7. Shell Programming and Scripting

echo backspace

Hello Forum: I am trying to find a meaning to this echo escape character: echo -e "\b" Can someone tell me or give me examples of the effect that this has when used. I know that \b is the backspace, but I cannot visualise it use like any other escape such as: echo -e "\n" Thanks. --Willie (10 Replies)
Discussion started by: willie
10 Replies

8. Shell Programming and Scripting

Grep command to show only process name

Can I modify the grep command to show only a process name? Currently I run ps -efa | grep chk_web to get the following: mousr 3395 1 0 09:36:06 pts/10 0:00 sh /var/opt/scripts/chk_web.sh Can this be changed in any way to get only: /var/opt/scripts/chk_web.sh or chk_web.sh. I... (3 Replies)
Discussion started by: runnerpaul
3 Replies

9. Shell Programming and Scripting

How to show progress bar for a running process

Hi, I have 2 shell scripts ,one for taking hot backup of oracle Database while other is for progress bar. But I don't have an idea hoe should I incorporate the shell script of progress bar in my hot backup code . Please help. My shell script for hot backup is as below: ... (0 Replies)
Discussion started by: dwiravi
0 Replies

10. Shell Programming and Scripting

echo doesnot show output

hi every one , i m new in unix . i m trying shell scripting . set v = abc echo $v but it does not show any output . please help me (4 Replies)
Discussion started by: samy123
4 Replies
Login or Register to Ask a Question