snippetbashTip
IFS — `$IFS` (Internal Field Separator) is a special environment variable that defines the delimiter used
Viewed 0 times
commandspecialifsfieldcliseparatorinternal
Problem
How to use the
IFS command: $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. More information: <https://www.gnu.org/software/bash/manual/bash.html#Word-Splitting>.Solution
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. More information: <https://www.gnu.org/software/bash/manual/bash.html#Word-Splitting>.View the current
$IFS value:echo "$IFS"Change the
$IFS value:IFS="{{:}}"Reset
$IFS to default:IFS=
Temporarily change the $IFS value in a subshell:
(IFS="{{:}}"; echo "{{one:two:three}}")
\t\n'Temporarily change the
$IFS value in a subshell:%%CODEBLOCK_3%%
Code Snippets
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}}")Context
tldr-pages: common/IFS
Revisions (0)
No revisions yet.