[Gllug] Bash scripting question
Tom Schutzer-Weissmann
trmsw at yahoo.co.uk
Thu Aug 10 19:23:49 UTC 2006
On Thu, 2006-08-10 at 18:52 +0100, Dylan wrote:
> which should extract the comments from the filename in $1 into the array
> $tags. So far so good. Unfortunately I find that the input is split up at
> spaces and line breaks, meaning that multi-word tags get distributed across
> more than one array element.
Setting the IFS (input field separator) environment variable should do
the trick:
tom at t40:~$ for i in `cat foo` ; do echo $i ; done
foo
bar
bar
Barbar
is
no
foo
he
is
Celeste's
husband,
and
an
elephant
tom at t40:~$ export IFS='
> '
tom at t40:~$ #there was no space after the first ', only a linebreak
tom at t40:~$ for i in `cat foo` ; do echo $i ; done
foo bar bar
Barbar is no foo
he is Celeste's husband, and an elephant
___________________________________________________________
All new Yahoo! Mail "The new Interface is stunning in its simplicity and ease of use." - PC Magazine
http://uk.docs.yahoo.com/nowyoucan.html
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list