在文本文档1.txt第5行(假设文件行数大于5)后面增加如下内容:
# This is a test file.
# Test insert line into this file.
#!/bin/bash
#这个脚本用来给文件增加行
#作者:猿课-阿铭 www.apelearn.com
#日期:2018-11-01
n=0
cat 1.txt |while read line
do
n=$[$n+1]
if [ $n -eq 5 ]
then
echo $line
echo -e "# This is a test file.\n# Test insert line into this file."
else
echo $line
fi
done