Bash: Show IFS value

From FVue

Jump to: navigation, search

Contents

Problem

How do I check the value of the IFS (Internal Field Separator) variable? The default value is space, tab and newline so echo $IFS would show me just whitespace...

Solution 1: od

$ echo -n "$IFS" | od -abc
0000000  sp  ht  nl
        040 011 012
             \t  \n
0000003

Solution 2: cat

$ echo -n "$IFS" | cat -vTE
 ^I$

Restore default IFS

$ IFS=$' \t\n'

Backup and restore IFS

$ OLDIFS=$IFS IFS=$'\n'
$ # do something
$ IFS=$OLDIFS

Comments

blog comments powered by Disqus

Personal tools