2013年12月18日水曜日

すぐに忘れる sed コマンド

-n 指定した条件だけ表示
,  コンマで範囲指定

パターンマッチした行の削除
sed '/^#/d' .bashrc
sed '/^$/d' .bashrc

指定行を削除
sed '3d' sample.txt
sed '3,10d' sample.txt

指定行を表示
sed -n '3p' sample.txt
sed -n '3,9p' sample.txt
sed -n '4,/Hello/p' sample.txt
sed -n '/Tokyo/,/Osaka/p' sample.txt

grep
sed -n '/[abc]/p' sample.txt

head
sed 10q sample.txt

0 件のコメント:

コメントを投稿