在文件中的变量后写入新行
Writing new line after variable in file
我正在 bash 中编写脚本,我正在使用临时文件来存储我需要的一些数字。我收到几个 grep 的数字,想把它写入文件
每个数字后换行,最后一个除外。
myparts=$(grep -f parts.txt number.log | awk -F'[][]' '{print }'| sort | uniq)
echo -e $myparts+'\n' >> tempfile
这是我尝试过的,但没有奏效。
+
不是 shell.
中的字符串连接运算符
echo -e "$myparts\n" >> tempfile
我正在 bash 中编写脚本,我正在使用临时文件来存储我需要的一些数字。我收到几个 grep 的数字,想把它写入文件 每个数字后换行,最后一个除外。
myparts=$(grep -f parts.txt number.log | awk -F'[][]' '{print }'| sort | uniq)
echo -e $myparts+'\n' >> tempfile
这是我尝试过的,但没有奏效。
+
不是 shell.
echo -e "$myparts\n" >> tempfile