IFS (Internal Field Separator) is a special shell variable in Bash that defines field delimiter characters used for word splitting expansion and read command parsing.

Bash IFS CSV Parsing Script

parse_csv.shbash
#!/usr/bin/env bash
 
# Preserve original IFS separator
OLD_IFS=$IFS
 
# Set IFS to comma for parsing CSV line
IFS=","
 
line="root,1000,Linux Admin,/bin/bash"
read -r username uid role shell <<< "$line"
 
echo "User: $username | Shell: $shell"
 
# Restore original IFS
IFS=$OLD_IFS