I have the following script. It prints all of first characters to console from passwd, but my expectation was to get only one character and for the program to then terminate.
#!/bin/sh
cat /etc/passwd |
while read -r line
do
echo ${line} |
grep -o . |
while read char
do
echo ${char}
exit 1
done
done
Actual output:
r
b
d
a
(etc)
Expected output:
r