Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Adding text to the beginning of a file



On Sat, Mar 17, 2007 at 09:28:51AM -0400, Scott Robbins wrote:
> > export IFS=$'\n'
> > for file in `ls`;do echo $file; done
> 
> I didn't know that one.  I do find that setting it null also works
> 
> export IFS=""

Hmm. Yeah, it does, but I don't get why. I would expect no "separating"
to take place in that case.

Doing a little research turned up the fact that if IFS is not set, it
behaves differently than if it is set with no value. (In that case it
reverts to the default <space><tab><newline> behavior.)

> With yours, I found that mistyping, and leaving out the $ set n as the
> separator.  
> 
> touch 1 2 3 "stupid file name"
> 
> export IFS='\n'   [note the typo]

This sets the field separators to backslash and 'n'. If you had a file
name with a backslash in it, it would also be split.

try touch ab\\cd 

Ed


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links