Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Jan 2004 17:28:15 -0600
From:      "Andrew L. Gould" <algould@datawok.com>
To:        "Xpression" <admin@atenas.cult.cu>, "FreeBSD-questions" <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Script question...
Message-ID:  <200401121728.15261.algould@datawok.com>
In-Reply-To: <001601c3d960$696a5550$0901a8c0@bloodlust>
References:  <001601c3d960$696a5550$0901a8c0@bloodlust>

next in thread | previous in thread | raw e-mail | index | archive | help
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




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