shell script to find filename & line count of each file, now insert this record into Oracle table

前端 未结 4 1983
暗喜
暗喜 2021-01-23 12:59

I have to find the filename available in a folder with each file line count. And then, i will have kind of two column data.

Now i have to insert this record into a orac

4条回答
  •  难免孤独
    2021-01-23 13:20

    I do not know Oracle, but it appears that the SQL syntax is quite similar to MySQL.

    In essence you, you would do what you have done here with one minor change.

    wc -l *| egrep -v " total$" | awk '{print $2 "|" $1}' > output.txt
    

    You would write an SQL script called thesql.sql that would look like the following:

    LOAD DATA
    INFILE output.txt
    INTO TABLE yourtable
    FIELDS TERMINATED BY '|'
    (col1, col2)
    

    Then, in your script (this is where I am hazy), have a line like this:

    sqlplus /@ @thesql.sql
    

    I found some help from a couple of different sources - here and here.

    Hope this helps!

提交回复
热议问题