shell 读取文件

#!/bin/bash
content=`cat test.txt`
echo "begin"
for i in $content
do
    echo $i
done

 

读取前10行

head -n 10 test.txt

读取后10行

tail -n 10 test.txt

读取第5行

sed -n "5,1p" test.txt

读取5到10行

sed -n “5,10p” test.txt

 

posted @ 2017-01-14 22:24  raindream  阅读(632)  评论(0)    收藏  举报