Вы можете использовать head
с echo
для достижения этого
cat <outputfilename> | head -n -1 && echo -e " this is test4\n this is test5\n this is test6\n}"
Если вы хотите добавить вывод в файл, просто используйте «>
» перенаправление вывода
(cat <outputfilename> | head -n -1 && echo -e " this is test4\n this is test5\n this is test6\n}") > <RESULTFILENAME>