Bash Script - Reading User Input while Processing output from Command within Bash
I am trying to get a users input by using read -p method while it inside a loop which is processing an output from a command by using read -r method. read -p method does not work it seems to be still reading data from the output from the command. any ideas?
Code:
while read -r LLINE; do |
both «read» commands work with the same file descriptor, the default STDIN, because you did not specify any; since you attached STDOUT from «find» command to STDIN with a pipe, it works exactly like you explained; what kind of ideas you are asking about?
|
What I want to achive
What i was tryinbg to do was to process the output from the find command query as it is generated and get a user to choose to archive, delete or skip any actions on the large file. I did not want to put the output from the find into an array nor file then process the array/file, Has this would give a period of time where there is no activity on screen whilw the output from the command was collected.
So is there any way round this issue with read using stdin channel for the both reads? I would be greatfully for any assistance on this. |
Put this:
Code:
THISTTY=$(tty) Wrap your read like so: Code:
exec 6<&0 |
Thanks Keith, it works like a charm and the day is not wasted because I've learned something new today.
|
No probs, but if you are going to be doing any bash scripting you will want to grab a copy of the advanced bash scripting guide here:
http://www.tldp.org/guides.html |
All times are GMT -5. The time now is 01:09 PM. |