Negate bvecs in x-axis or any axis

Dear @jdtournier ,
I hope you are doing great. I have a simple question for you. For instance, I have bvecs for 5 DWI volumes.

0 0 0.22 0.24 0.25
0 0 0.44 0.45 0.50
0 0 0.99 0.98 0.97

I am trying to negate the bvecs of the X-axis like this.

-0 -0 -0.22 -0.24 -0.25
0 0 0.44 0.45 0.50
0 0 0.99 0.98 0.97

I am using MATLAB for this. I am wondering whether I can do this in the BASH terminal.

I am waiting for your favorable response as soon as possible.

Many Thanks,
Suren

You could do it in native bash, but it’s easier using tools like awk, e.g.:

awk '{ if (NR==1) { for (i=1;i<=NF;++i) printf -$i" "; printf "\n"; } else { print $0; } }' < bvec_in > bvec_out

Note the syntax may differ on macOS, it all depends on which version of awk you have installed…