iptables あれこれをここに記す
行番号を表示
/sbin/iptables -L -nv --line-number
行番号でルールを削除
/sbin/iptables -D INPUT "$NUM"
stringで弾く
/sbin/iptables -I INPUT -p tcp -m string --string "www.hoge.com" --algo bm --dport 80 --to 128 -j REJECT
rsync すごい(既存のoptionに便利なのがあった。賢い)
hard linkでバックアップを世代管理
test.sh
#!/bin/bash # delete oldest backup if [ -d test_bk10 ] ;then /bin/rm -rf test_bk10 fi # backup dir rename(lotate) for i in 9 8 7 6 5 4 3 2 1 0;do if [ -d test_bk"$i" ] ;then l=`expr $i + 1` mv test_bk$i test_bk$l; fi done # submit backup rsync -avzP --delete --link-dest=../test_bk1 test/ test_bk0
rsyncのoption説明
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) -v, --verbose increase verbosity -z, --compress compress file data during the transfer -P same as --partial --progress でかいサイズのファイルをrsyncで転送中に中断した場合、その後に再開すると中断後から行ってくれる! --link-dest=DIR This option behaves like --copy-dest, but unchanged files are hard linked from DIR to the destination directory. The files must be identical in all preserved attributes (e.g. permissions, possibly ownership) in order for the files to be linked together. An example: DIR は例の場合の「test_bk0」の相対パスを入力しないといけない。
- 考慮点・足りない点
- 世代管理は日付でやる予定
- renameももっとかっこよく出来る?
- rsyncのエラーハンドリングは必須
awkで項目ごとに集計
集計対象の内容が以下の場合
cat test.list aaa 1 aaa 1 bbb 5 aaa 1 bbb 10 ccc 4 aaa 1 ccc 7 aaa 1 bbb 2
1項目目のaaa,bbb,cccごとに次の項目を集計する場合が以下のawkで。
awk '{ARY[$1]+=$2}END{for(i in ARY){printf "%s,%d\n",i,ARY[i]}}' test.list ccc,11 bbb,17 aaa,5