我正在尝试在 bash 中运行以下脚本:
#! /bin/Bash
cp '../Text_Files_Backups/'*.txt .
sed -i '1,/Ref/d' *.txt
##Deletes all lines from the begining of file up to and including the line that includes the text 'Ref'
##
sed -i -b '/^.$/,$d' *.txt
##Deletes all blank lines and text following and including the first blank line
sed -i 's/\([(a-zA-Z) ]\)\([(1-9)][(0-9)][ ][ ]\)/\1\n\2/g' *.txt
##Searches document for any instance of a letter character immediately followed by a 2 digit number ##immediately followed by 2 blank spaces
## <or>
##a blank space immediately followed by a 2 digit number immediately followed by 2 blank spaces
## and inserts a new line immediately prior to the 2 digit number
exit
每一行都经过单独测试,并按其应有的功能运行,除非将它们组合成一个脚本。
第一个文件似乎很好。接下来的 4 个文件是空白的。然后接下来的2个文件很好。这在我需要运行它的 550 个文件中以看似随机的间隔保持不变。
有任何想法吗?
谢谢。