#!/bin/bash
for dir in $(ls -l |grep ^d)
do
if [ -d $dir ]; then
cd $dir
for file in `ls ./`
do
#統計行數
count=$(cat $file | wc -l)
for ((i=1;i<=$count;i++))
do
j=$(expr $i + 1)
k=$i,$j'p'
one=$(sed -n $k $file)
date=$(echo $one | awk '{print $1}' )
tim=$(echo $one | awk '{print $2}' )
create_time=$date' '$tim
if [[ $i == 1 ]];then
echo $date
fi
echo $i/$count
session_id=$(echo $one | awk '{print $4}')
content=$(echo $one | awk '{print $5}')
mysql -hlocalhost -uroot -pvfc123456 <<EOF
use test
INSERT INTO test.log (id, session_id, content, create_time, is_trans) VALUES (NULL, '$session_id', '$content', '$create_time', '0');
EOF
done
done
cd ..
echo 'finished'
fi
done
linux遍歷文件以及文件夾入數據庫
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
周(di)哥(di)進來看看
LaoTrue男
2019-04-20 19:55:58
想找個寫react的師傅
沙鑫741
2019-02-14 20:07:13
vscode 編輯器配置
沙鑫741
2018-12-25 20:11:47
axios 封裝帶請求頻繁取消上一次請求
沙鑫741
2018-12-10 19:39:39
手機端網頁根據屏幕大小自適應
沙鑫741
2018-12-07 20:00:12
在全球經濟持續低迷情況下,看唯品會如何逆襲
zc1989621machao
2018-09-06 00:30:40
WaitHandle 中 set() reSet() waione關係
zc1989621machao
2018-09-06 00:30:40
CPU卡指令文件讀取算法
qq_29961715
2018-09-03 23:17:20
面試
q2369645143
2018-09-01 11:02:39
uploadfiy
q2369645143
2018-09-01 11:02:39