Skip to main content
2 votes

How do I read multiple lines from STDIN into a variable?

~ $ txt=; while read line; do [[ $line == '.' ]] && break; txt+="$line\n"; done; txt=${txt:0:-2} Hi! This should work, right? Cheers! . ~ $ echo $txt Hi! This should work, right? ...
René Fokkema's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible