Artificial intelligent assistant

Combine Files with similar names [![enter image description here][1]][1]I have the following set of files: lh.aparc.DKTatlas40.stats lh.BA.stats lh.curv.stats lh.w-g.pct.stats rh.aparc.DKTatlas40.stats rh.BA.stats rh.curv.stats rh.w-g.pct.stats lh.aparc.a2009s.stats lh.aparc.stats lh.BA.thresh.stats lh.entorhinal_exvivo.stats rh.aparc.a2009s.stats rh.aparc.stats rh.BA.thresh.stats rh.entorhinal_exvivo.stats I want to combine each 'rh' file with each 'lh' file For example I need to combine lh.aparc.DKTatlas40.stats + rh.aparc.DKTatlas40.stats = merge.aparc.DKTatlas40.stats How do I do it?

for lh in lh*; do
cat "$lh" "rh${lh#lh}" >"merge${lh#lh}"
done


This will concatenate each `lh` file with the corresponding `rh` file and save the concatenated version as `merge` (followed by whatever comes after `lh` in the filename).

The parameter expansion `${lh#lh}` will remove the string `lh` from the start of the value of `$lh` (e.g. turn `lh.BA.stats` into `.BA.stats`).

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 8ce06d85cc9e43c783915fa0e7d75c21