I have seen this question a few times, but the solutions I cannot get to work.
I have the following command:
printf '%s\n' "${fa[@]}" | xargs -n 3 bash -c 'cat *-$2.ss | sed -n 11,1p ; echo $0 $1 $2;'
where
printf '%s\n' "${fa[@]}"
O00238 115 03
O00238 126 04
and cat *-$2.ss
gives:
1 D C 0.999 0.000 0.000
2 L C 0.940 0.034 0.012
3 H C 0.971 0.005 0.015
4 P C 0.977 0.005 0.009
5 T C 0.970 0.009 0.018
6 L C 0.977 0.006 0.011
7 P C 0.864 0.027 0.014
8 P C 0.966 0.018 0.011
9 L C 0.920 0.038 0.039
10 K C 0.924 0.043 0.039
11 D C 0.935 0.036 0.035
12 R C 0.934 0.023 0.053
13 D C 0.932 0.022 0.046
14 F C 0.878 0.041 0.088
15 V C 0.805 0.031 0.198
16 D C 0.834 0.039 0.108
17 G C 0.882 0.019 0.071
18 P C 0.800 0.031 0.132
19 I C 0.893 0.039 0.070
20 H C 0.823 0.024 0.179
21 H C 0.920 0.026 0.070
22 R C 0.996 0.001 0.002
running the command then produces
11 D C 0.935 0.036 0.035
O00238 115 03
11 K C 0.449 0.252 0.270
O00238 126 04
Even lines are the output of sed -n 11,1p
, odd lines the output of echo $0 $1 $2
How do I pair the output on the same line i.e.
11 D C 0.935 0.036 0.035 O00238 115 03
11 K C 0.449 0.252 0.270 O00238 126 04
I have tried:
printf '%s\n' "${fa[@]}" | xargs -n 3 bash -c 'cat *-$2.ss | {sed -n 11,1p ; echo $0 $1 $2;} | tr "\n" " "'
as suggested here: Concatenate in bash the output of two commands without newline character
however I get
O00238: -c: line 0: syntax error near unexpected token `}'
O00238: -c: line 0: `cat *-$2.ss | {sed -n 11,1p ; echo $0 $1 $2;} | tr "\n" " "'
What is the problem?