Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
testttest

What is going wrong here?

share|improve this question
    
I am suggesting to rewrite your script in sh. faqs.org/faqs/unix-faq/shell/csh-whynot –  arved May 10 '12 at 8:01
add comment

1 Answer

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

or

/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
add comment

Your Answer

 
discard

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.