Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a script which produces a file 'Detail.out'. I know that the script is completed whenever the file contains a certain number of lines (roughly 21025). So I find myself sitting at the command prompt running:

[me@somewhere myDir]$ wc -l */Detail.out
  21025 A/Detail.out
  21025 B/Detail.out
  21025 C/Detail.out
  12995 D/Detail.out
  10652 E/Detail.out
   3481 F/Detail.out
  21027 G/Detail.out
  21025 H/Detail.out
  21025 I/Detail.out
  ...   ...

I've used tail -f to watch a specific file, but I'd like to follow the output of the wc -l */Detail.out command shown above. Is this possible? I'm currently using tcsh in Ubuntu 11.04 if that matters.

share|improve this question

2 Answers 2

up vote 12 down vote accepted

Try the watch command, although I suspect just about everyone has written their own version at one time or another. (The cheapie version is while :; do clear; "$@"; sleep 5; done.)

share|improve this answer

Not sure if you know that but you can redirect the output of a program to a file as well. See http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html Thus, another way might be to simply redirect the output to a file and then use tail on that file as you are already used to do.

$ find . -name "Detail.out" | xargs wc -l >> detail-out-list.txt

And in another Terminal you could run $ tail -f detail-out-list.txt as you are used to.

As Celeb noted that leaves some file around which may what you want (to further inspect that file or to have some history) or not and nothing gets executed periodically like watch does for you.

share|improve this answer
    
This does not address the OPs question at all, it just punts the work off to another command and requires a whole new layer of stuff to run and cleanup after. –  Caleb Jul 5 '11 at 7:49
    
@Caleb: I'm not clear on why this is such a terrible answer. The output file could be in /tmp, so there's no need to clean it up. I don't think the question was "how can I run a command repeatedly?" but "how can I follow a command that is run repeatedly?". So as far as I can see, it looks like this answers the OP's question... okay on more careful reading, I guess the question is ambiguous as presently posted: does "(run repeatedly)" mean "(which is being run repeatedly)" or "(that is to say, how do I run it repeatedly?)"? –  iconoclast Jul 24 '11 at 5:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.