トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS

sh:for/while:繰り返し処理 のバックアップソース(No.2)

*sh:ファイルを1行ずつ読み込む [#x0ad7f89]

よくググって書くのに覚えないので、メモ書き。

 #!/bin/sh
 
 while read LINE
 do 
 
     echo $LINE 
 
 done < “ファイル名”

***sshと組み合わせて使用 [#z1c49116]
複数台あるサーバのあるディレクトリのファイルについて、更新日が70日以内のファイルを探すスクリプトはこんな感じです。


 #!/bin/bash
 
 TARGETLIST=target.txt
 
 while read LINE
 do
   if [ "A" = "A$LINE" ] 
   then 
     continue
   fi
   echo $LINE
   ssh -n $LINE 'find /opt/batch/bin/ -name "ISB*" -mtime -70 -ls'
   echo ""
 done < $TARGETLIST
  
 


***リンク [#b947196e]

-[[http://shellscript.sunone.me/while.html]]
-[[http://www.sssg.org/blogs/naoya/archives/1124]]