# How to print whole array in tcsh

I want to print the whole array in tcsh, because then i want to pipe it to uniq, is there a way to do it in tcsh.

i had set array

and was printing it:

echo "$array"  but it ended up with error: Word too long, it works for smaller arrrays, Is there some simple way to do it? - Also posted on Stack Overflow here. – Keith Thompson Nov 7 '13 at 23:03 @Ricsie please show your whole script or steps you are performing. This could help to troubleshoot your problem. – val0x00ff Nov 7 '13 at 23:12 ## 1 Answer In tcsh you'd use arrays as follow. Define the array set myarray = ( element1 element2 element3 element4 etc )  Output the whole array printf '%s\n' "$array[-]"


Print element 1 to 3

printf '%s\n' "$array[1-3]"  NOTE: In Bash the first element of the array starts at 0 (zero). Also add set verbose on top of your script to see what lines are interpreted and where it fails. - How would that address the Word too long error? – Keith Thompson Nov 7 '13 at 23:04 @KeithThompson making sure he understands how arrays work in *csh shells. – val0x00ff Nov 7 '13 at 23:08 Ok, but echo "$array" should work perfectly well to print an entire array -- except for the "Word too long" problem, to which printf '%s\n' "$array[-]" is equally vulnerable. – Keith Thompson Nov 7 '13 at 23:10 @KeithThompson except he shows set array only which will result to nothing (empty) output. He probably is overriding the array somehow and resulting in the error. set array; echo$array should return nothing, let alone "Word too long" –  val0x00ff Nov 7 '13 at 23:16
Hmm. I assumed that set array was an abbreviation of the actual command he used. If he got "word too long", he's obviously setting it to something. Your recent comment on the question is a good one. –  Keith Thompson Nov 7 '13 at 23:25