Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'd like to create two files in /etc/skel using a script which does many other things in addition to the creation of the files in /etc/skel. The part from script regarding /etc/skel looks like this:

cat <<EOF > /etc/skel/.vimrc
:set nu
set incsearch
:set ignorecase
:set smartcase
:set ts=2
EOF

I tried adding && /etc/skel/.virc on the end of the first line in the script but to no avail. Is there any way to do that other than doing the whole cat again into the other file?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You can use tee.

tee /etc/skel/{.vimrc,.virc} > /dev/null <<EOF
:set nu
set incsearch
:set ignorecase
:set smartcase
:set ts=2
EOF
share|improve this answer
1  
Yet another useless use of cat. (since corrected) –  cjm Jul 11 '13 at 22:04
    
@cjm: Indeed. I have fixed the offending code. –  paraxor Jul 11 '13 at 22:13

You can make use of the fact that the here document created the file /etc/skel/.vimrc and make a copy of it:

cp /etc/skel/.vi{m,}rc

You put that line right after the here document.

share|improve this answer

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.