I have a bash script that I use mostly interactively. However, sometimes I enter some input in a script. After processing stdin in a loop, I copy the file using "-i" (interactive). However, this is never done (in handset mode), because (I think) the standard input has not been reset. To simplify the example:
#!/bin/bash
while read line
do
echo $line
done
cp -i afile bfile
Put this in t.sh and run with: ls | ./t.sh
Reading is not performed. I need to clear stdin before reading. How can I do that?
source
share