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

From Devinder K Rajput
Subject Re: Copy entire file as one field
Date
Msg-id OFAADBCCDB.29F8F5DF-ON86256C84.007A3867@ipaper.com
Whole thread Raw
In response to Copy entire file as one field  ("Warren Massengill" <warrenmassengill@hotmail.com>)
List pgsql-novice
Warren,

merge is an actual linux utility used to merge files.  When you ran the
command it found the system command before it could get to your script.  To
run your program, cd to the your program is  stored.  Then type in
   ./merge

This will execute the program in your current directory.  This should do
the trick,

Devinder




                    
                      "Warren Massengill"
                    
                      <warrenmassengill@hotm        To:       olly@lfix.co.uk
                    
                      ail.com>                      cc:       pgsql-novice@postgresql.org
                    
                      Sent by:                      Subject:  Re: [NOVICE] Copy entire file as one field
                    
                      pgsql-novice-owner@pos
                    
                      tgresql.org
                    

                    

                    
                      12/03/2002 01:48 PM
                    

                    

                    




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


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html







pgsql-novice by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: Copy entire file as one field
Next
From: Joshua Daniel Franklin
Date:
Subject: Re: Detecting table/row locks