Files
tldr/pages.zh/common/ifs.md

21 lines
534 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# IFS
> IFS内部字段分隔符是一个特殊的环境变量用于定义在Unix shell中进行单词拆分时使用的分隔符。
> IFS的默认值是空格、制表符和换行符。这三个字符作为分隔符使用。
> 更多信息:<https://www.gnu.org/software/bash/manual/html_node/Word-Splitting.html>。
- 查看当前的IFS值
`echo "$IFS"`
- 修改IFS值
`IFS="{{:}}"`
- 将IFS重置为默认值
`IFS=$' \t\n'`
- 在子shell中临时改变IFS值
`(IFS="{{:}}"; echo "{{one:two:three}}")`