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 Sun, Mar 18, 2007 at 12:30:15AM +0900, Edward Wright wrote:
> 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. 

Do you mean that you think it would have just listed everything as one
long file name?  I would guess that ls has other means of figuring what
is a different file.  (Of course, if ls' method of differentation was
perfect, we wouldn't have to do tricks with spaces in the file name.)
:)

However, I don't really grok IFS very well at all--with me, it's usually
trial and error when I try to use it. 


> 
> 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.)

That would be expected I think.  (I'm afraid of getting deeply into this
discussion as I fear I'll show a great deal of ignorance.)  

> 
> > With yours, I found that mistyping, and leaving out the $ set n as the
> > separator.  
> > 
> > 
> > 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 

Yup, it did the same thing

ab
cd

Thanks.


-- 

Scott Robbins

PGP keyID EB3467D6
( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

Whistler: Bottom line is, even if you see them coming, you're not
ready for the big moments. No one asks for their life to change, 
not really. But it does. So, what are we, helpless? Puppets? Nah.
The big moments are gonna come, you can't help that. It's what 
you do afterwards that counts. That's when you find out who you 
are. 



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links