1.判斷2個目錄同時存在再執行shell命令
#!/bin/bash
testpath="/volume01/edit_high/"
testpath1="/volume01_bak/edit_high/"
if [ -d "$testpath" ]&&[ -d "$testpath1" ]; then
echo "ok";
rsync -a --delete /volume01/* /volume01_bak/ fi
2.在多個目錄中查詢超過7天的檔案
#!/bin/bash
delfile()
dirlist="/vms_transfer/cztvcloud/mixiu_new/complete /vms_transfer/cztvcloud/shixian_new/complete /vms_transfer/cztvcloud/channel_new
/complete"
for i in $dirlist;do
[ ! -z $i ] && delfile; d
one
3.從文字中讀取ip位址,並修改密碼,前提伺服器免密碼登陸。
cat iplist
192.168.122.3
192.168.122.4
192.168.122.5
# cat chpass.sh
#!/usr/bin/env bash
while read line
doecho "------------- $line --------------"
ssh $line -n "echo '123456' | passwd --stdin root"
if [ $? -eq 0 ];then
echo "$line sucess."
else
echo "$line failed."
fidone < iplist
另外方法:
for i in `cat user.txt`; do useradd $i; done
4.除/home/dmtsai目錄外,/home和/etc目錄的所有東西都打包?
tar --exclude /home/dmtsai -zcvf myfile.tar.gz /home/* /etc
tar -cvf /root/backup/`date+%y%m%d`_etc /etc
帶時間的備份檔案
shell常用檔案操作命令
echo date y m d true financials.logtail n 1 financials.log 賦值給變數 finc flag tail n 1 financials.log sed n 1p financials.log cut d f1 第一行第一列 賦值給變數 finc ...
shell常用操作命令系列 軟體操作命令
rpm常用操作 rpm ivh lynx rpm安裝 rpm e lynx 解除安裝包 rpm e lynx nodeps 強制解除安裝 rpm qa 檢視所有安裝的rpm包 rpm qa grep lynx 查詢包是否安裝 rpm ql 軟體包路徑 rpm uvh 公升級包 rpm test ly...
HDFS操作常用的Shell命令
hadoop fs copyfromlocal uri f 如果檔案存在,則覆蓋 從本地檔案系統考貝到集群上 將乙個本地檔案系統的原始檔或多個原始檔追加到目標檔案系統 hadoop fs copytolocal ignorecrc crc uri ignorecrc 選項複製crc校驗失敗的文 件 ...