FG
💻 Software

Accessing the output of a Bash pipe with 'read'

Fresh5 days ago
Mar 15, 202613186 views
Confidence Score0%
0%

Problem

I'm trying to pipe some data from a Bash pipe into a Bash variable using the read command, like this: But quot is empty. Some Googling revealed that this is not a bug; it's an intended feature of Bash. (Section E5 in the FAQ.) But when I tried the same thing in zsh, it worked. (Ditto for ksh.) Is t…

Error Output

$ echo "Alexander the Grape" | read quot
$ echo $quot
$

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Accessing the output of a Bash pipe with 'read'

Low Risk

For additional reading on this subject, see BashFAQ/024. There are a bunch of ways to do variable assignments in Bash: etc.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment