我需要帮助从文件中提取行的某些部分。
这是我的文件的样子:
testfile.txt
This is a test line 1 $#%#
This is a test line 2 $#%#
This is a test line 3 $#%#
This is a test line 4 $#%#
This is a test line 5 $#%#
This is a test line 6 $#%#
This is a test line 7 $#%#
这是我的 bash 脚本:
#!/bin/bash
while read line
do
#echo $line
FilterString=${line:22:26}
echo $FilterString>>testfile2.txt
done<testfile.txt
上面的脚本获取字符串$#%#
并写入临时文件
我的问题:
而不是写字符串,$#%#
我想要除字符串之外的所有内容$#%#
写入文件。所以我希望我的最终输出文件看起来像:
testfile.txt
This is a test line 1
This is a test line 2
This is a test line 3
This is a test line 4
This is a test line 5
This is a test line 6
This is a test line 7
还请建议我做这件事的最佳工具
提前致谢。