Collect1
while [ 1 ]; do sleep 1; ll; done # 無限迴圈
i=0; while [ $i -lt 10 ]; do echo $i;let "i=$i+1"; done #有限迴圈 可生成值
cat feeler-consumer-task.log.2018-12-09.0 | while read line; do echo $line; sleep 1s; done #逐行輸出檔案
for i in /opt/logs/feeler-consumer-task* ; do ls -l $i; done #多層級遍歷輸出資料夾
if [ 1 -eq 1 ]; then ll ;fi # 常用判斷 1
if [[ 0 -eq 0 && 1 -eq 0 ]]; then ll ;fi # 常用判斷 2
if [ 0 -eq 0 -a 1 -eq 0 ]; then ll ;fi # 常用判斷 3 -a相當於與
if [ ! -e /tmp/111 -a -z "$a" ]; then ll ;fi # 不存在111檔案 且a變數長度為0 則執行ll
Collect2
ps -ef | grep java | grep -v tail # 檢視程式,篩選出java的,排除tail的
echo love | tr -d "oe" # 刪除字元oe,輸出 lv
echo 'a:b:c' | tr -s ':' '-' # 替換字元:為*,輸出 a-b-c
echo 'a:b:c' | awk -F ':' '{print $1 "+" $3 "+" $2}' # 按:切分後,按下標調整順序,空格分割輸出。a+c+b
awk -F':' '{print $1}' temp2.log | awk '{ arr[$1]++ } END { for( no in arr) { print no , arr[no] } }' | sort -n -t" " -k 2 -r # 一句話實現group by
grep -rn 'ReturnMessageListCount' info.log | awk -F"|" '$3 ==11 {print $0 }' #實現過濾和條件判斷輸出
echo 'a:b:c' | sed -e 's#:#*#g' # 替換字元:為*,輸出 a*b*c
zgrep " body size " feeler-consume-task-info.1.log.gz | awk '{sum+=$NF}END{print sum}' #過濾和家和
Collect3
sudo su admin # 切換為admin身份
sudo -u admin kill -9 xxx # 以admin身份執行kill命令
ps -ef # 檢視java程式
zip -9 -p haha -r bak.zip src # 以9級壓縮比、haha為密碼,壓縮src目錄,壓縮後的檔案是bak.zip
Collect4
curl -H "auth_token:1141d565-a0ac-4577-b816-61c884d888a8" -H "Content-Type:application/json" -X POST --data '{"priority": "normal", "messages": [{"targetType":"its just string","targetValue":"CN_4a4d496fb13027584c3459d3f6d5584d","message":"xxxxxxxxx","priority":"high","appId":"123456"}]}' http://10.13.30.114:8082/server/v1/message/sms/unicast_batch
curl -H "Content-Type:application/json" -X POST --data '{"registrationId":"CN_f733779a0b7fee6c93ac2d4d065ee04b","app_key":"3K0tr62sko6fQHMDqYVEci3X","blackList":[{"appId":"12124145214","source":"net"}],"type":"A","sign_method":"MD5","timestamp":"1540278529604","sign":"2db303aa0f79940a5cdc749a3f72a0a7"}' https://test.opush-test.wanyol.com/sms/v1/sn/blacklist
{"targetType":"2","targetValue":"CN_ad714e2162abba1f42f136dc8cfd2094","message":{"key1":"value1","key2":"value2","key3":"value3"}}
{"priority":"high","messages":[{"targetType":"2","targetValue":"CN_ad714e2162abba1f42f136dc8cfd2094","message":{"key1":"value1","key2":"value2","key3":"value3"}},{"targetType":"2","targetValue":"CN_ad714e2162abba1f42f136dc8cfd2094","message":{"key3":"value3"}}]}
{"messages":[{"targetValue":"CN_ad714e2162abba1f42f136dc8cfd2094","targetType":2,"message":{"key1":"value1","key2":"value2","key3":"value3"}},{"targetValue":"CN_ad714e2162abba1f42f136dc8cfd2094","targetType":2,"message":{"key1":"value1"}}],"priority":"high"}
curl -H "auth_token:37c7c35a-123c-46cd-b8aa-67bb079f2b70" -H "Content-Type:application/x-www-form-urlencoded" -d message='{"data_message":{"description":"xxx","content":"xxx"},"target_type":"2","target_value":"CN_4a4d496fb13027584c3459d3f6d5584d"}' http://10.13.30.114:8082/server/v1/message/instant/data_message/unicast