1

I use a program that recreates a certain directory structure each time it is run, then populates it with all kinds of data.

I keep a terminal window "open at" one of the subdirectories of that directory, where I wish to list and browse the data being created.

However in that window, each time the program re-runs, listing the current directory shows 0 files - bash isn't up-to-date on the directory - presumably because it had been recreated. My workaround is to cd again to the same directory, but is there something else that will maintain the shell window's correct view of the recreated directory at all times?

Currently I found cd . being the simplest workaround, but of course it needs to be used every time. Would be nice being able to avoid that alltogether.

If relevant, this is Ubuntu.

  • 1
    Better may be: cd ..; watch "ls subdir" – Jeff Schaller Nov 14 '15 at 18:03
  • @JeffSchaller you might want to post watch ls subdir as an answer – Sergiy Kolodyazhnyy Nov 14 '15 at 21:24
  • If the existing answer solved your problem, please consider accepting it with the checkmark; thank you! – Jeff Schaller Sep 1 '17 at 1:04
  • Thanks for reawakening this post and thanks for the answer few years ago, but no, the provided answer was a nice suggestion, but I do not consider it a solution. Not sure why you are trying to press on that, but thanks again for the answer. – Matan Sep 1 '17 at 8:00
2

I use a program that recreates a certain directory structure each time it is run ... Is there something else that will maintain the shell window's correct view of the recreated directory at all times?

Not directly, no. Your shell is in no-man's-land after re-running your program. The safest solution (if you insist on removing the top-level directory) is to keep your shell cd'd above it (cd ..) and run something like:

watch "ls subdir"

...to have it show you updates as they happen.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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