Skip to main content
format commands as code (i.e. pre-formatted)
Source Link

I really only use read with "while" and a do loop:
echo "This is NOT a test." | while read -r a b c theRest; do
echo "$a" "$b" "$theRest"; done
This

echo "This is NOT a test." | while read -r a b c theRest; do  
echo "$a" "$b" "$theRest"; done  

This is a test.
For what it's worth, I have seen the recommendation to always use -r with the read command in bash.

I really only use read with "while" and a do loop:
echo "This is NOT a test." | while read -r a b c theRest; do
echo "$a" "$b" "$theRest"; done
This is a test.
For what it's worth, I have seen the recommendation to always use -r with the read command in bash.

I really only use read with "while" and a do loop:

echo "This is NOT a test." | while read -r a b c theRest; do  
echo "$a" "$b" "$theRest"; done  

This is a test.
For what it's worth, I have seen the recommendation to always use -r with the read command in bash.

Improved formating and clarity.
Source Link

I really only use read with "while" and a do loop: 
echo "This is notNOT a test"test." | while read -r a b c theRest; do echo
echo "$a" "$b" "$theRest"; done 
This is a test.
For what it's worth, I have seen the recommendation to always use -r with the read command in bash.

I really only use read with "while" and a do loop: echo "This is not a test" | while read -r a b c theRest; do echo "$a" "$b" "$theRest"; done This is a test For what it's worth, I have seen the recommendation to always use -r with read in bash.

I really only use read with "while" and a do loop: 
echo "This is NOT a test." | while read -r a b c theRest; do
echo "$a" "$b" "$theRest"; done 
This is a test.
For what it's worth, I have seen the recommendation to always use -r with the read command in bash.

Source Link

I really only use read with "while" and a do loop: echo "This is not a test" | while read -r a b c theRest; do echo "$a" "$b" "$theRest"; done This is a test For what it's worth, I have seen the recommendation to always use -r with read in bash.