Parse Delimited Data With IFS

Split a simple CSV or TSV line into fields using the IFS separator.

macOSbashshellscriptingLow risk
Set IFS=, before read to split each line into comma-separated fields.

01Command

Command
$ while IFS=, read -r name age; do echo "$name is $age"; done < people.csv

02What it does

Setting IFS to a delimiter makes read assign one field per variable, which handles simple CSV and TSV without an external parser. It is a lightweight approach for scripts that consume machine-generated data.

03Risk

RiskLow risk
RequirementsmacOS default zsh/bash (bash 3.2+; some features need bash 4+ via Homebrew)
CompatibilitymacOS with bash 3.2+ (GNU bash 4+ via Homebrew for advanced features)
!Warning: IFS parsing does not understand quoted fields containing the delimiter; use csvkit or a real parser for messy CSV.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

Last verified: 2026-10-13 · Category: Developer