運維DOS腳本

--拷貝文件到指定目錄

rem 獲取前一天的備份
set today=%date:~8,2%
set /a day=%today%-1
set yesterday=%date:~0,4%-%date:~5,2%-%day%
rem copy目錄F:\testcopy所有txt文件到F:\testcopy01
forfiles /p F:\testcopy /s /M *.txt /D +%yesterday% /C "cmd /c xcopy /Y @path F:\testcopy01"
rem 清理N天前備份
forfiles /p F:\testcopy01 /s /M *.txt /D -2 /C "cmd /c del /Q @path"

--輸出文件中最後一行的最後一列

@echo off
set date=%date:~0,4%%date:~5,2%%date:~8,2%
rem clients相關數據輸出到e:\result.txt,>覆蓋源文件,>>追加文件
type e:\VT_Sys%date%.txt | findstr "clients" > e:\result.txt
set filePath=e:\result.txt
for /f "delims=: tokens=4" %%i in (%filePath%) do (set lastLine=%%~i)
rem 把最後一行以:分隔,只把最終數字數據輸出到result.txt文件
echo %lastLine% >  e:\result.txt
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章