Files
bash/tests/read10.sub
2024-04-25 15:50:39 -04:00

18 lines
459 B
Plaintext

# the read builtin uses a consistent value of IFS to split the input line
# into fields
IFS=:
INPUT=',:abc:def,ghi'
read -r IFS var rest <<<"$INPUT"
printf 'IFS=[%s] var=[%s] rest=[%s]\n' "$IFS" "$var" "$rest"
IFS=:
INPUT=':abc:def,ghi'
read -r IFS var rest <<<"$INPUT"
printf 'IFS=[%s] var=[%s] rest=[%s]\n' "$IFS" "$var" "$rest"
IFS=:
INPUT=' : abc:def,ghi '
read -r IFS var rest <<<"$INPUT"
printf 'IFS=[%s] var=[%s] rest=[%s]\n' "$IFS" "$var" "$rest"