西西軟件園多重安全檢測(cè)下載網(wǎng)站、值得信賴的軟件下載站!
軟件
軟件
文章
搜索

首頁編程開發(fā)php教程 → 使用Bash腳本批量刪除PHP臨時(shí)文件.out文件列表

使用Bash腳本批量刪除PHP臨時(shí)文件.out文件列表

相關(guān)軟件相關(guān)文章發(fā)表評(píng)論 來源:本站整理時(shí)間:2010/8/9 2:20:48字體大。A-A+

作者:佚名點(diǎn)擊:148次評(píng)論:0次標(biāo)簽: PHP

  • 類型:服務(wù)器區(qū)大。21M語言:中文 評(píng)分:7.5
  • 標(biāo)簽:
立即下載

PHP每天生成一個(gè)存有系統(tǒng)要?jiǎng)h除的臨時(shí)文件的.out文件列表,由bash腳本逐行通過讀取.out文件(每一行代表一個(gè)待刪除的文件)挨個(gè)刪除,代碼如下(dl.sh):

  #!/bin/bash

  # Shell script utility to delete file.

  # You can call script as follows, to read myfile.txt:

  # ./dl.sh or.txt

  # Copyright (c) 2009 kokko <http://www.kokkowon.com/>

  #User define Fuction(UDF)

  processLine(){

  line="$@" #get all args

  if [ ! -f $FILE ]; then

  echo "$line does not exists"

  else

  echo "$line"

  rm -rf $line

  fi

  }

  #echo Please enter the file name:

  #read FILE

  if [ ! "$1" == "" ]; then

  FILE="$1"

  else

  echo Please enter the file name:

  read FILE

  fi

  if [ ! -f $FILE ]; then

  echo "$FILE does not exists"

  exit 1

  elif [ ! -r $FILE ]; then

  echo "$FILE cann't read"

  fi

  #read $FILE using the file descriptors

  BAKIFS=$IFS

  IFS=$(echo -en "\n\b")

  exec 3<&0

  exec 0<"$FILE"

  while read -r line

  do

  processLine $line

  done

  exec 0<&3

  IFS=$BAKIFS

  exit 0

  執(zhí)行:

  kokkowon@itbeing.com [~/www]# ./dl.sh ./temp.out

  結(jié)果:

  ./message.tmp

  ./ECShop_V2.7.1_UTF8_Release1228.zip

  ./captcha.tmp

  ./index.tmp

  ./goods_script.tmp

  ./region.tmp

  ./article.tmp

  ./comment.tmp

  ./animated_favicon.gif

  ./auction.tmp

  ./catalog.tmp

  ./category.tmp

  ./affiche.tmp

  ./group_buy.tmp

  ./search.tmp

  ./favicon.ico

  ./itbeing/Cache/776e414da1b246fca4e72f34d6e5cce9.tmp

  ./itbeing/Cache/e8a01c49e3bd6881d1526bce80cbcad7.tmp

  ./itbeing/Cache/13da2f5482df2335081ce60c3ac5828c.tmp

  ./itbeing/Cache/aec1e7b1c552ce75969652a157572320.tmp

  ./pm.tmp

  ./respond.tmp

  ./exchange.tmp

  ./flow.tmp

  ./myship.tmp

  ./sitemaps.tmp

  ./snatch.tmp

  ./error_log

  ./article_cat.tmp

    相關(guān)評(píng)論

    閱讀本文后您有什么感想? 已有人給出評(píng)價(jià)!

    • 8 喜歡喜歡
    • 3 頂
    • 1 難過難過
    • 5 囧
    • 3 圍觀圍觀
    • 2 無聊無聊

    熱門評(píng)論

    最新評(píng)論

    發(fā)表評(píng)論 查看所有評(píng)論(0)

    昵稱:
    表情: 高興 可 汗 我不要 害羞 好 下下下 送花 屎 親親
    字?jǐn)?shù): 0/500 (您的評(píng)論需要經(jīng)過審核才能顯示)