Chinaunix首页 | 论坛 | 博客
  • 博客访问: 26187684
  • 博文数量: 2065
  • 博客积分: 10377
  • 博客等级: 上将
  • 技术积分: 21525
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-04 17:50
文章分类

全部博文(2065)

文章存档

2012年(2)

2011年(19)

2010年(1160)

2009年(969)

2008年(153)

分类: LINUX

2010-06-27 21:06:42

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


#!/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

 原文地址
阅读(1029) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~