Home » SQL & PL/SQL » SQL & PL/SQL » Unix and Oracle database
Unix and Oracle database [message #200873] Wed, 01 November 2006 14:08 Go to next message
nbachani
Messages: 2
Registered: October 2006
Junior Member
Hi,
My requirement is to have a shell script in unix that reads the filenames from a folder in unix and stores them in the database.
Please advise.
Thanks
Re: Unix and Oracle database [message #200880 is a reply to message #200873] Wed, 01 November 2006 14:34 Go to previous message
Mahesh Rajendran
Messages: 10672
Registered: March 2002
Location: oracleDocoVille
Senior Member
Account Moderator
oracle@mutation#cat somescript
#!/usr/bin/bash
ls -lrt /tmp | awk '{print "insert into filenames values ('\''"$9"'\'');"}' >somefile.sql
sqlplus -s scott/tiger <<EOF
set echo off;
set termout off;
@somefile.sql
commit;
exit;
EOF

oracle@mutation#ls -lrt /tmp | wc -l
      15

oracle@mutation#somescript

Commit complete.

oracle@mutation#count mutation scott.filenames

Table:scott.filenames

  COUNT(*)
----------
        15


Edit:
"$9" is position 9 on the ls -lrt output.
It may actually vary . Tweak it accordingly or use some other utility like "find".

[Updated on: Wed, 01 November 2006 14:45]

Report message to a moderator

Previous Topic: select records in proper order
Next Topic: how to query using sysdate 13 hours ago
Goto Forum:
  


Current Time: Mon Dec 05 05:00:35 CST 2016

Total time taken to generate the page: 0.19881 seconds