cmd

ipアドレスを取得

cmd

centos $ ifconfig eth0 | grep -v inet6 | grep inet | awk '{print $2;}' | cut -f2 -d ':'osx % ifconfig en0 | grep -v inet6 | grep inet | awk '{print $2;}'

改行コード一括置換

cmd

lf % find . -type f | xargs nkf --overwrite -Lu crlf % find . -type f | xargs nkf --overwrite -Lw

osx で useradd, groupadd

% man dsclaユーザ一覧 % dscl . -list /Users UniqueID | sort -n -k 2グループ一覧 % dscl . -list /Groups PrimaryGroupID | sort -n -k 2使用できるGIDを取得 % NEWGID=$(expr $(dscacheutil -q group | awk '{print $2}' | sort -ug | tail -1) + 1) $ …

素早くバックアップをとる

cmd

% cp filename{,.bak}

lessで行番号表示

cmd

-N 行番号表示 -n 行番号非表示 -m 行のパーセンテージ表示 -M 行のパーセンテージと行番号表示

ディレクトリの総使用量

cmd

% du -s target-dir

.svnディレクトリの削除

cmd

% find . -type d -name "*svn*"|xargs rm -rf

日本語を含む cut

cmd

shift_jis な sjis.csv の1番目と10番目のフィールドを切り出して hoge に書き出す。 % env LC_ALL=ja_JP.SJIS cut -d',' -f1,10 < sjis.csv > hoge

開いてるportの確認

cmd

% netstat -na | grep LISTEN

pandoc

cmd

port install pandoc はエラー build.target build-all make build-all するとエラー ―for Haskell programmers onlyですか。Variantsはだめですか。 なんで、Google Code Archive - Long-term storage for Google Code Project Hosting. % make % make test…

CSSTidy

cmd

オプション % csstidy - --silent=true --preserve_css=true --template=default --compress_font-weight=false --lowercase_s=true --case_properties=1 --compress_colors=false

ユーザー追加

#!/bin/sh USER=$1 PASS=$2 USERADD=`which useradd` PERL=`which perl` if [ $# -lt 2 ]; then cat <

16進表示

cmd

% echo -n a |hexdump -C

MD5ハッシュを求める

cmd

$ echo -n 'pass' | md5

telnetで、smtp,pop

cmd

smtp $ telnet hoge.example.com 25 Trying 210.154.87.18 ... Connected to hoge.example.com Escape character is '^]'. 220 hoge.example.com ESMTP ... HELO hoge.example.com 250 hoge.example.com Hello pc20.lo.ash.jp [10.0.1.20], pleased to meet …

shift_jisなhtmlをutf-8へ

cmd

やっつけ $ find . -type f -name ?*.html |perl -nle '`iconv -f SHIFT_JIS -t UTF-8 $_>$_.buf`;' $ perl -p -i.html -e 's/(x-sjis|Shift_JIS)/utf-8/g;' *.buf $ find . -type f -name ?*.html | xargs rm $ find . -type f -name ?*.buf |perl -nle '$f…

ディレクトリーの場合のみ実行ビットを立てる。

cmd

chmod -R u+rwX * chmod -R go+X * 404 Blog Not Found:unix - permissionあれこれ

dig, nslookup

cmd

@IT:DNS Tips:digコマンドとnslookupコマンドの違いとは @IT:DNS Tips:digコマンドとは ネームサーバ $ dig example.com ns $ nslookup -type=NS example.com 正引き $ dig example.com a $ nslookup www.example.com 逆引き $ nslookup 192.0.34.166 …

Postfixでキューのクリア

cmd

$ sudo postsuper -d ALL

tcpdumpの使い方

cmd

$ sudo tcpdump -i en1 -s 65535 -w oreore.cap tcp port 80

圧縮・解凍

cmd

.tar.gz 解凍 $ tar zxvf filename [-C dest_dir]圧縮 $ tar zcvf backup.tar.gz file1 file2中身の確認 $ tar tzvf file.tar.gz .zip 解凍 $ unzip hoge.zip $ unzip -d dest_dir hoge.zip圧縮 $ zip backup.zip file1 file2 $ zip -r backup.zip target_di…

date

cmd

$ date '+%Y/%m/%d %H:%M:%S' $ echo `date '+%Y/%m/%d %H:%M:%S'` > hoge

shellスクリプトの構文チェック

$ /bin/sh -n file