I'm running into some weirdness trying to explicitly set the special variable in bash, the Internal Field Separator to be a space, a new line and a tab. This is in GNU bash, version 3.2.39(1)-release (x86_64-pc-linux-gnu)
I would like to be able to explicitly set the Internal Field Separator to be a space, a new line and a tab. I would expect the backslash sequences to be interpreted, but they seem not to be. Despite many HOWTOs, Tutorials, and guides only setup 'one' below successfully assigns all three.
# one
export IFS=`/bin/echo -ne " \t\n"`
echo "$IFS" | cat -vte
These others below fail, usually by making the letters 't' and 'n' into field separators. That is not the behavior I expect, I would expect the backslash sequences to be interpreted properly:
# two
export IFS=" \t\n"
echo "$IFS" | cat -vte
# three
export IFS=$" \t\n"
echo "$IFS" | cat -vte
# four
export IFS=$' \t\n'
echo "$IFS" | cat -vte
Here is the problem in a different form:
$ FOO=$'a\n a';echo $FOO
a a
$ FOO=$"a\n a";echo $FOO
a\n a
$ FOO="a\n a";echo $FOO
a\n a
$ FOO='a\n a';echo $FOO
a\n a
Bookmarks