Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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

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.

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.