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

从文件中读取特定行的shell脚本

百度收藏 QQ搜藏

代码:

#!/bin/sh
#set -x
if [ "$#" -lt 1 ];then
echo "Usage $0 [file] "
exit 1
fi
echo "Enter the line you want to choose from:"
read FromLine
echo "Enter the line you want to choose to:"
read ToLine

rm -rf temp.txt
Line=`echo "$ToLine-$FromLine" | bc`

x=0
exec < $i # opens the file you want choose the line from
while read line # read from the file
do
if [ $x -lt $Line ];then
printf "%s\n" "$line" >>temp.txt
x=`expr $x + 1`
else
echo "DONE"
exit 1
fi
done

#set +x

上一篇:一个关于安全的简单脚本 下一篇:一个丢硬币的脚本

power by soyo123 2007-2008