From owner-freebsd-questions@FreeBSD.ORG Fri Feb 3 20:43:31 2006 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A5F9F16A420 for ; Fri, 3 Feb 2006 20:43:31 +0000 (GMT) (envelope-from willmaier@ml1.net) Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3D4E343D45 for ; Fri, 3 Feb 2006 20:43:30 +0000 (GMT) (envelope-from willmaier@ml1.net) Received: from frontend1.internal (mysql-sessions.internal [10.202.2.149]) by frontend1.messagingengine.com (Postfix) with ESMTP id 74326D30E53 for ; Fri, 3 Feb 2006 15:43:26 -0500 (EST) Received: from frontend2.messagingengine.com ([10.202.2.151]) by frontend1.internal (MEProxy); Fri, 03 Feb 2006 15:43:26 -0500 X-Sasl-enc: H23+bycS0WQLakQi/ZiZtBUKVYCbBBhjP1k8rCnNj/eS 1138999405 Received: from localhost (mdsnwikwbas08-pool4-a199.mdsnwikw.tds.net [69.129.195.199]) by frontend2.messagingengine.com (Postfix) with ESMTP id 3AB295714AA for ; Fri, 3 Feb 2006 15:43:24 -0500 (EST) Date: Fri, 3 Feb 2006 14:43:23 -0600 From: Will Maier To: freebsd-questions@freebsd.org Message-ID: <20060203204323.GV1940@merkur.atekomi.net> Mail-Followup-To: freebsd-questions@freebsd.org References: <7.0.1.0.2.20060203110425.01744328@broadpark.no> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7.0.1.0.2.20060203110425.01744328@broadpark.no> User-Agent: Mutt/1.5.9i Subject: Re: Script to generate names X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Feb 2006 20:43:31 -0000 On Fri, Feb 03, 2006 at 11:08:04AM +0100, Kristian Vaaf wrote: > 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. How bout this? Works on OpenBSD's sh; I assume it works on Free's sh as well. Might take a while to run, though... #!/bin/sh notify () { if [ ${VERBOSE} ]; then echo "===> $*" fi } VERBOSE=1 LIST1=/path/to/list1 LIST2=/path/to/list2 LIST3=/path/to/list3 NEWWORDCT=0 if [ ! -f "${LIST3}" ]; then touch ${LIST3} fi for WORD1 in $(< ${LIST1}); do for WORD2 in $(< ${LIST2}); do echo "${WORD1}${WORD2}" >> ${LIST3} echo "${WORD2}${WORD1}" >> ${LIST3} NEWWORDCT=$((NEWWORDCT + 2)) done done sort ${LIST3} | uniq > ${LIST3}-sorted notify "Created ${NEWWORDCT} new words in file ${LIST3}; a sorted version" notify "can be found at ${LIST3}-sorted." -- o--------------------------{ Will Maier }--------------------------o | jabber:..wcmaier@jabber.ccc.de | email:..........wcmaier@ml1.net | | \.........wcmaier@cae.wisc.edu | \..........wcmaier@cae.wisc.edu | *------------------[ BSD Unix: Live Free or Die ]------------------*