婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 利用shell刪除數(shù)據(jù)表中指定信息和字段對應(yīng)的文件

利用shell刪除數(shù)據(jù)表中指定信息和字段對應(yīng)的文件

熱門標簽:佛山高德地圖標注中心 東莞電銷機器人價格一覽表 旅游地圖標注大全 百度地圖標注圖標更換 百度地圖的地圖標注 杭州機器人外呼系統(tǒng) 陜西電銷卡外呼系統(tǒng)怎么安裝 地圖標注超出范圍怎么辦 excel地址地圖標注

利用mysql shell命令讀取數(shù)據(jù)庫信息,刪除指定字段,以及字段對應(yīng)的文件,適用Linux平臺。

前面變量定義為數(shù)據(jù)基本配置

復(fù)制代碼 代碼如下:

#!/bin/bash
#Program
#    delete the database'info whick state is 3
#History:
#  2014/2/23  cjp  First release
#  2014/3/5/  cjp  change value'setting on 117
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/usr/local/bin:/usr/local/sbin:~/bin
export PATH

host="127.0.0.1"
port="3306"
user="user"
passwd="passwd"
dbname="database"
tablename="table"
field="t_field"
outField="t_id,t_path"
fileRootPath="/var/www/html/apath"
filePath=""

#checkdown data
mysql -h$host -P$port -u$user -p$passwd $dbname -e "SET NAMES utf8;SELECT ${outField} FROM ${tablename} WHERE ${field} = 3" > data_info

date -d '1970-01-01 UTC 946684800 seconds' +"%Y-%m-%d %z" >> del_log.log

#delete image file and mysql data
sed '1d' data_info | while read line
do
  echo $line > findtemp
  awk '{print $2}' findtemp > imagetemp
  cat imagetemp | while read imagedata
  do
    filePath=${fileRootPath}${imagedata}
    echo $filePath >> del_log.log
    rm -f $filePath
  done

  awk '{print $1}' findtemp > idtemp
  cat idtemp | while read iddata
  do
    mysql -h$host -P$port -u$user -p$passwd $dbname -e "SET NAMES utf8;DELETE FROM ${tablename} WHERE s_id = ${iddata}"
  done
done

rm -f data_info
rm -f imagetemp
rm -f idtemp

echo "^-^ clean!"

您可能感興趣的文章:
  • shell備份文件、重命名文件、刪除指定文件的3個腳本分享
  • shell中刪除文件中重復(fù)行的方法
  • Shell中刪除某些文件外所有文件的3個方法

標簽:西藏 青島 朝陽 南充 隨州 雅安 通遼 延邊

巨人網(wǎng)絡(luò)通訊聲明:本文標題《利用shell刪除數(shù)據(jù)表中指定信息和字段對應(yīng)的文件》,本文關(guān)鍵詞  利用,shell,刪除,數(shù)據(jù),表中,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《利用shell刪除數(shù)據(jù)表中指定信息和字段對應(yīng)的文件》相關(guān)的同類信息!
  • 本頁收集關(guān)于利用shell刪除數(shù)據(jù)表中指定信息和字段對應(yīng)的文件的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 潮州市| 明溪县| 闽清县| 丽水市| 宜城市| 镇雄县| 教育| 光山县| 鄂温| 望都县| 迁安市| 榆林市| 外汇| 托克逊县| 津南区| 富顺县| 黑山县| 湘乡市| 宣城市| 肇州县| 宁远县| 当雄县| 博野县| 龙胜| 沾益县| 莎车县| 晋州市| 潜江市| 项城市| 绥中县| 筠连县| 广昌县| 绵竹市| 博兴县| 辽宁省| 泰顺县| 贺兰县| 清徐县| 密云县| 锡林郭勒盟| 丰原市|