Ambiguous redirect error when using cat with regex

273 Views Asked by At

I have a dir with files : X, A_1, A_2, A_3, etc.. I want to append X to A_1, A_2,A_3,.. and write to A_1,A_2,A_3,... That is : cat X >> A_1, cat X >> A2, cat X >> A3

When I do

cat X >> A_* 

I get

-bash: A_*: ambiguous redirect

What am I doing wrong here ?

1

There are 1 best solutions below

0
On

While that would work in zsh with the multios option set, bash doesn't allow you to specify more than one redirect target per stream. You could do this with a loop, but your best option is to use tee.

cat X | tee -a A_* >/dev/null