Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 13 Aug 2007 08:16:27 +0400 (GST)
From:      Rakhesh Sasidharan <rakhesh@rakhesh.com>
To:        Manolis Kiagias <sonicy@otenet.gr>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Question on the IFS variable (not a FreeBSD question)
Message-ID:  <20070813081337.E44584@obelix.home.rakhesh.com>
In-Reply-To: <46BF5AE4.2010206@otenet.gr>
References:  <20070812195535.V86618@obelix.home.rakhesh.com> <46BF5AE4.2010206@otenet.gr>

next in thread | previous in thread | raw e-mail | index | archive | help

Manolis Kiagias wrote:

> Do a little experiment (inspired from the post stated above):
> #export IFS="\n"
> #printf '<%s>\n' "$IFS" | cat -vt
> will give <\n> ==> not what you expect
> #export IFS='\n'
> #printf '<%s>\n' "$IFS" | cat -vt
> will give <\n> ==> again, not what you expect
> #export IFS=$'\n'
> #printf '<%s>\n' "$IFS" | cat -vt
> will give
> <
>>
> definitely a new line character (finally...)
> I am not certain of the explanation, but from the above it seems to me
> the IFS does not evaluate special '\something' characters unless there
> is a $ in front. That is, of course, what you would do to get the value
> of a shell variable. It seems then these characters need to be evaluated
> in the same way.

Yup, that's what I too figured from my experiments. Strange.

Oh well ... good to know now that '\n' (even in double quotes etc) need 
not always refer to the newline. Sometimes the $ magic is required ... :-)

Thanks!
Rakhesh



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070813081337.E44584>