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

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

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

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

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

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

復制代碼 代碼如下:

#!/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中刪除文件中重復行的方法
  • Shell中刪除某些文件外所有文件的3個方法

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

巨人網(wǎng)絡通訊聲明:本文標題《利用shell刪除數(shù)據(jù)表中指定信息和字段對應的文件》,本文關鍵詞  利用,shell,刪除,數(shù)據(jù),表中,;如發(fā)現(xiàn)本文內(nèi)容存在版權問題,煩請?zhí)峁┫嚓P信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《利用shell刪除數(shù)據(jù)表中指定信息和字段對應的文件》相關的同類信息!
  • 本頁收集關于利用shell刪除數(shù)據(jù)表中指定信息和字段對應的文件的相關信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 应城市| 宝山区| 盘山县| 资兴市| 湘阴县| 丹巴县| 都昌县| 启东市| 定安县| 彭泽县| 且末县| 宁陵县| 肥东县| 武陟县| 侯马市| 卢湾区| 新干县| 万源市| 禹城市| 浏阳市| 娄底市| 双流县| 阿拉尔市| 信丰县| 读书| 高安市| 锦州市| 岳阳县| 山东| 平泉县| 玉屏| 鹿泉市| 蒲江县| 洛隆县| 芒康县| 贵溪市| 金门县| 华蓥市| 右玉县| 喀什市| 板桥市|