2013-07-01から1ヶ月間の記事一覧

複数ファイルを比較して、全てに共通した行のみを出力する

sh

下記の3つのファイルの場合file1 1 2 3 4 5 file2 7 6 5 4 3 file3 1 9 7 5 3 こんなものを出力 $ ./allcomm.sh file1 file2 file3 3 5 ソース allcomm.sh #!/bin/sh PREF=allcomm_tmp_sorted_ # 途中終了時のゴミ掃除 trap "rm -f $PREF*; exit 1" HUP INT …

コマンドラインオプション -a から -z まで

コマンドをつくって、そのオプションを実装するとき、 -a とか -e とか、この機能だとどのアルファベットを 割り当てるのが正当なのか悩むことがある。あと、このコマンドってこの引数使えるのかなとか、 あたりをつけたいときがある。こういう情報ってググ…

ssh が 目を離したすきに 切れちゃうのを 防ぎたい。

ssh/configの設定で「15秒おきに確認する」という設定をしておけばOK $ echo "ServerAliveInterval 15" >> ~/.ssh/config

djangoのカスタムコマンドの、実行中のコマンド名をとりたい。

djangoのカスタムコマンドの、実行中のコマンド名をとりたいけど djangoのBaseCommandクラスの中身とか読んでもコマンド名のとるほうほうなさそう。とりあえずはこれでとれる def get_command_name(): import sys return sys.argv[1] これでとれることはとれ…

pip install したら Cannot fetch index base URL http://pypi.python.org/simple/

pythonbrewからpythonを使用していて、 さくらのVPS上でpip install とはじめてやったら下記の通りでる。 Downloading/unpacking Django==1.3 Cannot fetch index base URL http://pypi.python.org/simple/ Could not find any downloads that satisfy the r…

sqliteでcsvファイルをインポート。sqliteすごい

sh

こんな感じのcsvファイル、tensuu.csvがあるとして 1,100 2,80 3,60 これをRDBテーブルにしたいsqliteすぐ出来る。 $ sqlite3 tmpdb -- テーブルを作って sqlite> create table score_table(id INTEGER, score INTEGER); -- 区切り文字を設定して sqlite> .s…

fatal: protocol error: bad line length character: # Us

いきなり以下のエラーが出てリモートのgitリポジトリに触れなくなった $ git pull origin master fatal: protocol error: bad line length character: # Us http://stackoverflow.com/questions/8170436/git-remote-error-fatal-protocol-error-bad-line-len…