「sed」(2007/03/22 (木) 11:25:47) の最新版変更点
追加された行は緑色になります。
削除された行は赤色になります。
*TIPS
-行を削除する
sed -e '1d' list.txt # 1行目
sed -e '1,5d' list.txt # 1~5行目
sed -e '$d' list.txt # 最終行
-カレントディレクトリから実行されたファイルまでの相対パス取得
print $0|sed -e "s/\(.*\)\/\(.*\)$/\1/"
-頭の0を削除する
echo 001 | sed -e "s/\(^0\{1,\}\)\(.*\)/\2/"
-頭の数字8文字を抜き出す
cat list.txt | sed -e "s/^\([0-9]\{8\}\).*/\1/"
*TIPS
-行を削除する
sed -e '1d' list.txt # 1行目
sed -e '1,5d' list.txt # 1~5行目
sed -e '$d' list.txt # 最終行
-カレントディレクトリから実行されたファイルまでの相対パス取得
print $0|sed -e "s/\(.*\)\/\(.*\)$/\1/"
-頭の0を削除する
echo 001 | sed -e "s/\(^0\{1,\}\)\(.*\)/\2/"
-頭の数字8文字を抜き出す
cat list.txt | sed -e "s/^\([0-9]\{8\}\).*/\1/"
-シングルクオートをエスケープする
sed -e 's/"/'\''/g' file
表示オプション
横に並べて表示:
変化行の前後のみ表示: