Jump to content

[SOLVED] BASH - status line, echo then delete?


markjoe

Recommended Posts

I have a bash script that processes a number of files. I would like to print the name of the current file being read, then delete it and print the next. So you see the current file only, not a big list of all files.

The only thing I could think of is echo the line, count the characters, build a string of that number of backspaces and echo that.

 

Anybody know an easier way?

Link to comment
https://forums.phpfreaks.com/topic/69387-solved-bash-status-line-echo-then-delete/
Share on other sites

I'm at work and without bash at the moment, but it should have the capabilities of bourne. Try something like this:

 

#!/bin/sh
echo "One...\c"
sleep 2;
echo "\rTwo...\c"
sleep 2;
echo "\rThree..."

 

If that doesn't work, I've seen a version of echo that accepts an argument to suppress the new line, rather than including \c in the string.

Looks like a great start. It does need the -e to acknowledge the escape chars in the quotes, I remembered after a few confusing runs.

Only issue with this is it only clears the number of characters needed to print next line.

 

1st echo "12345678" : 12345678

2nd echo "hello"      : hello678

 

...and so on.

 

ok, it just occured to me, back from testing it:

if I append a hand full of spaces to the end of the echo'ed string it looks perfect.

Maybe not the most elegant way of doing it, but functional.

People get uncomfortable not seeing any feedback, they start thinking something is wrong ( at least around here they do).

 

Thanks alot, that will do it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.