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?


1 Answer 1


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.

  • Using the -e flag has the same outcome as not using it, so that didn't work for me.
    – Utkonos
    May 10, 2012 at 1:14
  • I've even tried "echo_style=sysv" and "echo_style=both" and I still get the same results.
    – Utkonos
    May 10, 2012 at 1:26
  • I'm beginning to think I've found a bug.
    – Utkonos
    May 10, 2012 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, 2012 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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