Shell脚本逐行读取文本文件(不改变文本格式)

2019-09-23 09:26:51刘景俊


#!/bin/sh

testfile=$1
x=`wc -l $testfile |awk '{print $1}'`

i=1
while [ $i -le $x ]
do
    echo "`head -$i  $testfile | tail -1`"
    i=`expr $i + 1`
done