I was hoping to concatenate 186 3D+time datasets into one big 3D+time dataset. Their names are “Z_EC_thalamus_1” “Z_EC_thalamus_2” “Z_EC_thalamus_3” “Z_EC_thalamus_4” “Z_EC_thalamus_5” … How can I use 3dTcat to simply concatenate them? I don’t want to print all 186 names in one command.

Thanks all!


How about:

3dTcat -prefix OUTPUT Z_EC_thalamus_*

I have never tried concatenating 186 3D+time files. Hopefully you won’t run into memory issues on the computer…


ps: and that should concatenate them in the numerical order they are listed. Note that you might run into trouble if you want
Z_EC_thalamus_3 before Z_EC_thalamus_11-- the latter will come first, because the numbers aren’t zeropadded, such as Z_EC_thalamus_003 and Z_EC_thalamus_011, where “*3” would be earlier in the listing.

You will be able to see the ordering of the files in the header file’s history. Does the order matter for you?


Yes, it does look like the lack of zero padding might be a problem.
Assuming so, you can get around that by generating all of the
names (tcsh syntax). Start with a list of those integers, convert
spaces to commas, and use {} for the list generation. So try:

set nums = ( `count -digits 1 1 186` )
set clist = `echo $nums | sed 's/ /,/g'`
3dTcat -prefix Z_EC_thalamus_ALL Z_EC_thalamus_{$clist}+tlrc

I am assuming the +tlrc is appropriate…

  • rick

Thanks for your help.

But when I use your script, it occur such message:set nums = ( count -digits 1 1 186 ) bash: syntax error near unexpected token `(’

Thanks for your answer.

The order actually appear disorder.How can I fix this problem?

I do not know how to do that in bash (the {} part of 3dTcat,
in particular). So if you want to try it, please run it via tcsh.

Alternatively, and preferably, those dataset names should
be zero padded as mentioned by Paul. Then you would
not need such tricks.

  • rick

Thanks for your advise again!