Server Fault is a question and answer site for system and network administrators. 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'm trying to build my fstab during install with a script, so I want to have something like this:

printf '# Device\t\tMountpoint\tFSType\tOptions\t\tDump\tPass#' >> /mnt/etc/fstab
printf '\n/dev/ada0p4.elia\t/\t\tufs\trw\t\t1\t2' >> /mnt/etc/fstab
printf '\n/dev/ada0p3.eli\t\tnone\t\tswap\tsw\t\t0\t0' >> /mnt/etc/fstab
printf '\n/dev/ada0p2\t\t/unencrypted\tufs\tro\t\t1\t1' >> /mnt/etc/fstab

Is there a way to do this in csh with echo?

I have tried and it's not working properly. For example, here is a test and the output on my FreeBSD 9.0-RELEASE-p1 box:

# echo test\ttest > test
# cat test

What is going wrong here?

share|improve this question
I am suggesting to rewrite your script in sh. – arved May 10 '12 at 8:01
up vote 1 down vote accepted

Csh's builtin echo doesn't support this feature, so you'll need to type the path to the system's echo command. Additionally, you need to either add an additional backslash or put the backslash in quotes.

Either of these should work.

/usr/bin/echo test\\ttest > test


/usr/bin/echo 'test\ttest' > test

Contrary to what I posted before, you do not need to use the -e flag. That is only needed for GNU's echo command.

share|improve this answer
Using the -e flag has the same outcome as not using it, so that didn't work for me. – Utkonos May 10 '12 at 1:14
I've even tried "echo_style=sysv" and "echo_style=both" and I still get the same results. – Utkonos May 10 '12 at 1:26
I'm beginning to think I've found a bug. – Utkonos May 10 '12 at 1:26
Sorry, Utkonos. I should have tested this in csh before I posted. I'm updating my post with more information. – Nicholas May 10 '12 at 13:49

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.