这是我的代码;“test.txt”文件除了制表符外还包含更多的空行和空格。我想要去掉这些空格和空行,但我需要在开始st^
之前留下一个空行。如何做到?
sed "s/^[ ]*//" -i test.txt
cat $2 > /tmp/tt.txt
sed '/^$/d' test.txt > /tmp/tt.txt
echo " " >> test.txt
echo " " >> /tmp/tt.txt
mv /tmp/tt.txt test.txt
我得到的输出如下:
st^flower
p^rose
p^jasmine
st^animals
p^bear
p^elephant
我希望得到如下输出:
st^flower
p^rose
p^jasmine
st^animals
p^bear
p^elephant