markjoe Posted September 14, 2007 Share Posted September 14, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/69387-solved-bash-status-line-echo-then-delete/ Share on other sites More sharing options...
effigy Posted September 14, 2007 Share Posted September 14, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/69387-solved-bash-status-line-echo-then-delete/#findComment-348631 Share on other sites More sharing options...
markjoe Posted September 18, 2007 Author Share Posted September 18, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/69387-solved-bash-status-line-echo-then-delete/#findComment-350234 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.