2023-10-03 09:03:11 +05:30
|
|
|
# IFS
|
|
|
|
|
|
|
|
> IFS (Internal Field Separator) is a special environment variable that defines the delimiter used for word splitting in Unix shells.
|
|
|
|
> The default value of IFS is a space, tab, and newline. The three characters serve as delimiters.
|
2025-08-16 10:31:07 +03:00
|
|
|
> More information: <https://www.gnu.org/software/bash/manual/bash.html#Word-Splitting>.
|
2023-10-03 09:03:11 +05:30
|
|
|
|
|
|
|
- View the current IFS value:
|
|
|
|
|
|
|
|
`echo "$IFS"`
|
|
|
|
|
|
|
|
- Change the IFS value:
|
|
|
|
|
|
|
|
`IFS="{{:}}"`
|
|
|
|
|
|
|
|
- Reset IFS to default:
|
|
|
|
|
|
|
|
`IFS=$' \t\n'`
|
|
|
|
|
|
|
|
- Temporarily change the IFS value in a subshell:
|
|
|
|
|
|
|
|
`(IFS="{{:}}"; echo "{{one:two:three}}")`
|