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



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, Mar 17, 2007 at 09:29:58PM +0900, Edward Wright wrote:
> On Sat, Mar 17, 2007 at 09:06:40PM +0900, Stephen J. Turnbull wrote:
> > 
> > I don't know any way offhand to get file names with spaces to work
> > under for.  I tried setting IFS to newline and using `ls` instead of
> > *, but that seems to confuse bash completely in trying to parse the
> > for statement.
> 
> This works for me:
> 
> 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=""

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]

for i in `ls`; do echo $i; done
1
2
3
stupid file
ame

:)


- -- 

Scott Robbins

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

Willow: According to Freddy's latest editorial, 'The pep
rally is a place for pseudo-prostitutes to provoke men into a sexual
frenzy, which, when thwarted, results in pointless athletic
competition.'
Xander: And the down-side being?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (FreeBSD)

iD8DBQFF++0T+lTVdes0Z9YRAoxXAJ9b+SPCrIkO1k7r+c6V4CGUXs7RuwCgwQIp
FoLn4erkeRIKpDKZZL7gvZI=
=gzgB
-----END PGP SIGNATURE-----


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links