LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 06-11-2003, 05:59 PM   #1
brian0918
Member
 
Registered: Apr 2003
Posts: 87

Rep: Reputation: 15
file progress in xterm titlebar with bash


I'm almost able to have a file's progress outputted in the xterm titlebar. Right now, I have a function in .bashrc similar to this:


function prog(){

case $TERM in
xterm*)
PS1="\[\033]0; `grep "bleh" FILE1 -c` out of `grep "blah" FILE2 | awk '{ print $3 }'`\007\][bash:\W]$ "
;;
*)
PS1="[bash:\W]$ "
;;
esac
}


( i found the main code to this function on a site, i don't actually know much in the way of syntax)

What it does is count the number of times "bleh" appears in FILE1 -- in this way I can view how many iterations are done. It also reads the number of total iterations that will be done from FILE2 on the line that contains "blah" (in column 3 of that line).

When I execute:

$ prog

in the directory with these files, the titlebar changes to " x out of y ", BUT it only does this once. What I want it to do is, once prog is executed, have it repeatedly execute the command inside prog( ){....} (or better yet have it do it every few seconds), so that I can view the progress of the file.... until I hit CTRL+C (or something) and stop prog.


Thanks.

Last edited by brian0918; 06-11-2003 at 06:04 PM.
 
Old 06-11-2003, 06:23 PM   #2
hamster
Member
 
Registered: Apr 2003
Location: Waterford, Ireland
Distribution: Mandrivia 2006.1, Ubuntu 7.10
Posts: 188

Rep: Reputation: 30
You are treating it as a percentage... ie "15% of 100% completed" and so on.. ?
 
Old 06-11-2003, 06:39 PM   #3
brian0918
Member
 
Registered: Apr 2003
Posts: 87

Original Poster
Rep: Reputation: 15
sorta like that, more like:

123 out of 200

what I really need is some kind of while loop inside the prog( ) { ... }, along with a

sleep 10

so it doesn't constantly try to update.. the problem is I don't know the syntax (or if it's possible), and right now most of the internet can't be accessed (ISP problems).. but for some reason I can access this site.


Thanks.
 
Old 06-11-2003, 07:04 PM   #4
hamster
Member
 
Registered: Apr 2003
Location: Waterford, Ireland
Distribution: Mandrivia 2006.1, Ubuntu 7.10
Posts: 188

Rep: Reputation: 30
Hmmm... maybe you use the 'watch' cmd. Read up man on it.

that is...

watch # eg 'watch free' updates free cmd every 2 secs

I think you can specify in no. of secs too...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with combining bash with zenity --progress chii-chan Programming 2 05-06-2005 04:12 AM
Difference between bash and xterm krackerroot Red Hat 4 09-08-2003 11:32 AM
bash: How can I create a progress indicator? apeekaboo Programming 5 06-27-2003 11:41 AM
file progress brian0918 Linux - Newbie 9 06-11-2003 10:21 AM
xterm and titlebar King V Linux - Software 9 03-28-2003 11:46 AM


All times are GMT -5. The time now is 12:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration