I'm using sh (not bash/csh) on FreeBSD 11, and I don't understand this:
In console
Command: zpool status -v
Result:
pool: My_pool
state: ONLINE
status: One or more devices is currently being resilvered. The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
Splitting by lines and printing line at a time in a script:
#!/bin/sh
zp="$(zpool status -v)"
for line in $zp; do
echo "$line%"
done
Result:
pool:%
My_pool%
state:%
ONLINE%
status:%
One%
or%
more%
devices%
is%
currently%
being%
resilvered.%
The%
pool%
will%
continue%
to%
function,%
possibly%
in%
a%
degraded%
state.%
action:%
Wait%
According to all I can find, the syntax I'm using is correct for sh, and should read a line at a time, not a word at a time.
What am I missing?
read
loop. Considerwhile IFS= read -r L
andecho "$L"
. Quote your variables! – Chris Davies Nov 29 '17 at 08:07