Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 Feb 2006 15:14:15 -0500
From:      Parv <parv@pair.com>
To:        Kristian Vaaf <vaaf@broadpark.no>
Cc:        questions@freebsd.org
Subject:   Re: Script to generate names
Message-ID:  <20060203201415.GA3554@holestein.holy.cow>
In-Reply-To: <7.0.1.0.2.20060203110425.01744328@broadpark.no>
References:  <7.0.1.0.2.20060203110425.01744328@broadpark.no>

next in thread | previous in thread | raw e-mail | index | archive | help
in message <7.0.1.0.2.20060203110425.01744328@broadpark.no>,
wrote Kristian Vaaf thusly...
>
> I'm looking for pointers on how to make a simple shell script that
> will generate new names based on words (one word per line) from
> two different files, and output these to a third file.
...
> The first file will be a list of custom words.  The second file
> will be /usr/local/share/dict/words.
> 
> If the first word in the custom list is "apathy" and the first word in the
> dictionary file is "alien", it will generate:
> 
> apathyalien
> alienapathy
> 
> To a third file. And then continue with the rest of the words ...
> 
> A friend told me I could do something like this:

( reformatted for loop)
> for i in $(<list1) $(<list2)

That will generate, first, all the words from list1, then from
list2, in a sequence.  You may also get "too many args" or some such
error message if list[12] are sufficiently huge.

BTW, process substitution -- $( <file ) construct -- does not work
w/ /bin/sh of FreeBSD 6, but does w/ bash 3 or zsh 4.  So, when you
(general "you") post a shell question, please also mention the
intended shell being used.


> do echo -n $i
> done \

That will put all the words, from both list[12], in one long line,
on standard out.


> && echo >> list 3

At the end of the loop, you put a new lines in file "list" , not
"list3" (which i assume is only a typo).  Mind you nothing else
(namely the for loop output) goes in list3.


I do not have a solution yet, will post later if nobody else posts
(a working) one.


  - Parv

-- 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060203201415.GA3554>