if [[ -p /dev/stdin ]]; then
while IFS= read -r LINE; do
echo "Line: $LINE"
done
fi
A. The conditional is important to ensure that you have permissions to read the pipe.
B. The conditional isn't necessary as the read command will read any data sent to it and assign it to the $LINE variable.
C. You need to make sure /dev/stdin is a pipe. If it is we'll read the data using the read command. If it is not then you don't want to read from it. For instance if it were a block device.
D. You need to make sure /dev/stdin is a pipe. If it is we'll read the data using the read command. If it is not then we don't want to read from it. For instance if it were a block device.
No comments:
Post a Comment