Subject: Re: born shell (sh) and IFS
To: None <netbsd-users@netbsd.org>
From: Jukka Salmi <jukka-netbsd@2003.salmi.ch>
List: netbsd-users
Date: 11/03/2003 19:27:26
Hi,

John Maier --> netbsd-users (2003-11-03 11:49:06 -0600):
> I understand setting and using the IFS environmental variable, but I just
> want to set it to trigger on an EOL (carriage return) and I can't quite
> figure out how to do this?
> 
> I've dug the man page and it's useless and none of the tutorials I've found
> address special characters.
> 
> In this example, I want to print each line of rc.conf with a 'X' at the
> start and end of each line printed.  Instead I get a 'X' at the start and a
> 'X' at the end of the text....
> 
> #!/bin/sh
> 
> IFS=`echo`  # set a EOL to IFS or so I thought
> export IFS
> 
> lines=`cat /etc/rc.conf`
> 
> for line in $lines ; do
>  echo "X"$line"X"
> done
> 
> #EOF
> 
> 
> Any ideas?
> 
> jam

Try IFS=`echo;echo`. And don't ask why ;-)

HTH, Jukka

-- 
bashian roulette:
$ ((RANDOM%6)) || rm -rf ~