My gists
https://gist.github.com/ktkr3d
SSH ログインコマンドの短縮設定
- alias (~/.bash_aliases) を利用する方法
- function (~/.bash_aliases) を利用する方法
- ssh config (~/.ssh/config) を利用する方法
SSH のログインメッセージを抑止
1KB 未満のファイルを移動
$ mkdir -p ~/trash $ find . -size -1024c -exec mv -b {} ~/trash \;
|
$ find . -maxdepth 0 -size -1024c -exec mv -b {} ./failed/ \;
|
ファイルの重複検出
fdupes を利用したファイルの重複を検出
- インストール
$ sudo apt-get install fdupes
|
- 検出
- 最初以外を移動
$ mkdir -p ../trash/ && fdupes -fr . | xargs mv ../trash/
|
先頭1MB のMD5 ハッシュで重複ファイルを検出
- スクリプト
~/test.sh#!/bin/sh
cp /dev/null /tmp/list0.txt find . -type f -exec dd if={} bs=1024 count=1000 of=/tmp/work.bin \; -exec md5sum /tmp/work.bin >> /tmp/list0.txt \; -exec du {} >> /tmp/list0.txt \; sed ':loop; N; $!b loop; ;s/\/tmp\/work.bin\n//g' /tmp/list0.txt > /tmp/list1.txt sort /tmp/list1.txt | uniq -D -w 32 > /tmp/list2.txt rm /tmp/work.bin /tmp/list0.txt
|
- 実行
$ cd /PATH/TO/TARGET $ time ~/test.sh
|
- 結果
| 出力されるファイル |
内容 |
| /tmp/list1.txt |
全ファイルのハッシュ, サイズ, パス |
| /tmp/list2.txt |
重複ファイルのハッシュ, サイズ, パス |
~/.bash_aliases
flv ファイルをmp4 に変換
$ for f in *.flv ; do ffmpeg -i $f $f.mp4; done
|