سؤال

I am trying to copy a line from one file to another and add characters to the same line afterwards.

cat $INDIR/files |
while read
do
sed -n 27p $INDIR/files >> $OUTDIR/files
for i in {1..6} ; do echo -n '0.000000e+00 '; done >> $OUTDIR/files
done

It should look like this:

copied text 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 

But it looks like this:

copied text
0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00

How can I avoid the line break that is added to my output?

هل كانت مفيدة؟

المحلول

give this a try:

change your sed line into:

awk 'NR==27{printf "%s ", $0}' $INDIR/files >> $OUTDIR/files

as @devnull commented, you can also do:

sed .... |tr '\n' ' ' >>$OUTDIR/files
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top