From owner-freebsd-questions@FreeBSD.ORG Mon Jan 12 15:28:26 2004 Return-Path: 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 D2B7516A4CE for ; Mon, 12 Jan 2004 15:28:26 -0800 (PST) Received: from stork.mail.pas.earthlink.net (stork.mail.pas.earthlink.net [207.217.120.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id BD38943D5F for ; Mon, 12 Jan 2004 15:28:25 -0800 (PST) (envelope-from algould@datawok.com) Received: from 22-15.lctv-b4.cablelynx.com ([24.204.22.15] helo=yoda.datawok.com) by stork.mail.pas.earthlink.net with asmtp (TLSv1:RC4-MD5:128) (Exim 3.33 #1) id 1AgBTj-0006x2-00; Mon, 12 Jan 2004 15:28:15 -0800 From: "Andrew L. Gould" To: "Xpression" , "FreeBSD-questions" Date: Mon, 12 Jan 2004 17:28:15 -0600 User-Agent: KMail/1.5.4 References: <001601c3d960$696a5550$0901a8c0@bloodlust> In-Reply-To: <001601c3d960$696a5550$0901a8c0@bloodlust> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200401121728.15261.algould@datawok.com> X-ELNK-Trace: ee791d459e3d6817d780f4a490ca69564776905774d2ac4b0f044741a15cda54320cca5e7fc1d513350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c Subject: Re: Script question... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jan 2004 23:28:26 -0000 On Monday 12 January 2004 05:04 pm, Xpression wrote: > Hi list, I've making a script to write the content of three text files to > one file, but I want to separate each files by a delimiter like the name of > the file. > > This is the script: > > #! /bin/sh > path=/some/dir > if !([ -f $path/this.one ]); then > for file in $path/file1 $path/file2 $path/file3; do > cat $file >> $path/this.one > done > fi > > exit 0 > > By now the output is: > > Contents of file1 > Contents of file2 > Contents of file3 > > And I want to be like this: > ----------------------------------------------------------------------- > file1 > ----------------------------------------------------------------------- > Contents of file1 > ----------------------------------------------------------------------- > file2 > ----------------------------------------------------------------------- > Contents of file2 > ----------------------------------------------------------------------- > file3 > ----------------------------------------------------------------------- > Contents of file3 > > any suggestion ??? Thanks... I haven't tested it; but would this work: #! /bin/sh path=/some/dir if !([ -f $path/this.one ]); then for file in $path/file1 $path/file2 $path/file3; do echo '---------' >> $path/this.one echo $file >> $path/this.one cat $file >> $path/this.one done fi exit 0 Andrew Gould