|
Welcome to my blog!
删除一个文本中存在的空行 |
以下脚本是用来删除一个文本中存在的空行,我想在工作中是需要的.就写个出来供大家参考: ================================================= #!/bin/bash #del blank lines #Author Hahazhu 24/12/06 savefile="/tmp/tmp.$$" function usage(){ echo "Usage:`basename $0` file" exit 1 } function notice(){ echo "`basename $0` is not exists" exit 1 } if [ $# -eq 0 ];then usage else if [ -r $1 ];then cat $1|sed "/^$/d"|tee $savefile echo "Do you want save results?[Y/N]" read ANS case $ANS in Y|y) mv $savefile $1 if [ $? = 0 ];then echo "Save ok!" fi rm -f $savefile ;; N|n) rm -f $savefile ;; esac else notice fi fi |
[ 阅读全文 | 回复(0) | 引用通告 | 编辑 ] |
Post by badboy 发表于 2006-12-24 8:17:00
|
|
| |