tag2txt.sh
2008年08月31日 (shellscript)
source
#!/bin/sh
#html tag to text in html
if [ $# -ne 1 ]; then
echo "Usage: $0 HTML_FILE"
exit 1
elif [ ! -r $1 ]; then
echo "$1: permission denied"
exit 2
fi
sed \
-e '1,$s/\&/\&/g' \
-e '1,$s/</\</g' \
-e '1,$s/>/\>/g' \
$1
note
blogにHTMLソースを載せるときに便利かなと思う. 最初のif文は引数,ファイルが読めるかのチェック. 実際の処理部分は最後5行だけ.
PR
Comment