如何在shell脚本中如何提取某行并保存到新文件的末尾?

如何在shell脚本中如何提取某行并保存到新文件的末尾?

比如shell脚本的内容为

state1
state2

state3

如何分别提取这三行并保存到a.txt中,但不另起一行。
比如a.txt变成

state1 state2 state3
我只能提取为3行,求大神帮助

while read LINE;do echo -n $LINE >>output.txt;done < input.txt

cat shell.sh |xargs 1>>a.txt

加个awk的printf就好了
提取内容 | awk '{printf $0}'