Re: Copy entire file as one field - Mailing list pgsql-novice

From Warren Massengill
Subject Re: Copy entire file as one field
Date
Msg-id F147VJpjc0D543TuylJ0000eadd@hotmail.com
Whole thread Raw
In response to Copy entire file as one field  ("Warren Massengill" <warrenmassengill@hotmail.com>)
Responses Re: Copy entire file as one field
List pgsql-novice
My database is pg, the table is mail.
The small text files are in /home/kelly/message/.
The bash shell script is merge.

Somehow I failed to translate your instructions...

-----------------------------------------------------
#!/bin/bash

for f in `ls /home/kelly/message*`
do
        psql -d pg -c "INSERT INTO mail (message)
                                 VALUES ('`cat $f`')"
done

----------------------------------------------------
[kelly@localhost message]$ merge
merge: not enough arguments
merge: usage: merge [-AeEpqxX3] [-L lab [-L lab [-L lab]]] file1 file2 file3
merge aborted

----------------------------------------------------
Thanks,
Warren

>From: Oliver Elphick <olly@lfix.co.uk>
>To: Warren Massengill <warrenmassengill@hotmail.com>
>CC: pgsql-novice@postgresql.org
>Subject: Re: [NOVICE] Copy entire file as one field
>Date: 28 Nov 2002 07:43:12 +0000
>
>On Thu, 2002-11-28 at 00:40, Warren Massengill wrote:
> > How can I copy several hundred small text files into a database, each
>file
> > going into a field called 'message' and becomming one record (with or
> > without other fields) using psql?
>
>A bit of shell scripting:
>
>for f in `ls small_file*`
>do
>    psql -d mydatabase -c "INSERT INTO mytable (message)
>                 VALUES ('`cat $f`')"
>done
>
>
>--
>Oliver Elphick                                Oliver.Elphick@lfix.co.uk
>Isle of Wight, UK                             http://www.lfix.co.uk/oliver
>GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
>                  ========================================
>      "The earth is the LORD'S, and the fullness thereof; the
>       world, and they that dwell therein."       Psalms 24:1
><< signature.asc >>


_________________________________________________________________
Tired of spam? Get advanced junk mail protection with MSN 8.
http://join.msn.com/?page=features/junkmail


pgsql-novice by date:

Previous
From: Peter & Sarah Childs
Date:
Subject: Re: Starting postmaster in rc.local
Next
From: "Warren Massengill"
Date:
Subject: Re: Copy entire file as one field