Re: [SLUG] Bash Problem - SOLVED

From: thor_consulting@yahoo.com
Date: Thu Aug 07 2003 - 05:47:41 EDT


i'm sorry it took till 2 am for you to figure this one out but i needed my
beauty sleep

----- Original Message -----
From: "Paul M Foster" <paulf@quillandmouse.com>
To: "SLUG List" <slug@nks.net>
Sent: Thursday, August 07, 2003 02:07
Subject: Re: [SLUG] Bash Problem - SOLVED

> On Thu, Aug 07, 2003 at 12:38:49AM -0400, Paul M Foster wrote:
>
> > Within a bash script, I'm trying to feed each line of a file into a
> > variable, to wit:
> >
> > for line in `cat file`
> > do
> > do_whatever
> > done
> >
> > At the end of this operation, I want the $line variable to equal the
> > contents of a single line in the file. The problem is that the shell
> > breaks the line into _words_ if there are any spaces, tabs or newlines
> > in it. I understand why. It's because of the value of the IFS shell
> > variable. To get around this, I want to set the IFS variable to be
> > _only_ the newline. But I can't find a way to do it. The following do
> > not work:
> >
> > IFS=
> >
> > IFS=\n
> > IFS='\n'
> > IFS="\n"
>
> The answer (to set IFS to only a newline) is:
>
> IFS='
> '
>
> Paul
> -----------------------------------------------------------------------
> This list is provided as an unmoderated internet service by Networked
> Knowledge Systems (NKS). Views and opinions expressed in messages
> posted are those of the author and do not necessarily reflect the
> official policy or position of NKS or any of its employees.

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:13:12 EDT