专注各种脚本编程
Baidu
加入收藏夹
本站内容有下面分类知识,欢迎您的到来^_^
shell相关:指令篇 基础篇 脚本欣赏 编程实例 shell问问 shell视频教程 技巧篇 水平测试 E文资料 vi编辑器 高级Bash脚本编程指南
其他:mysql perl c语言 oracle
当前位置:| 主页>shell脚本欣赏>

逐行校正文件内容正确与否,起编辑的作用

百度收藏 QQ搜藏

作者:javalee

代码:
#!/bin/ksh
# Script name: Speller
#
#
# Purpose: Check and fix spelling errors in a file
#

exec < tmp   # opens the tmp file
while read line  # read from the tmp file
do
print $line
print -n "Is this word correct? [Y/N] "
read answer < /dev/tty  # read from the terminal
    case $answer in
    [Yy]*)
        continue
            ;;
    *)
        print "New word? "
        read word < /dev/tty
        sed "s/$line/$word/" tmp > error
        mv error tmp
        print $word has been changed.
            ;;
    esac
done

上一篇:没有了 下一篇:shell函数应用实例介绍

power by soyo123 2007-2008