[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: bash script




Almut Behrens wrote:

On Sat, Sep 17, 2005 at 02:33:03PM -0500, Rodney Richison wrote:
Am trying to automate some stuff for future installs.
I'd like to echo multiple lines to the end of a file. Like this

echo '. /etc/bash_completion' >> ~/.bashrc

But I'd like to add multiple lines at one time. Like the ones below. I realize I could cat them in from a text file, but I'd like to make this script non-dependant of other text files.

export LS_OPTIONS='--color=auto'
eval `dircolors`
alias ls='ls $LS_OPTIONS -F'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'

If I'm understanding you correctly, you probably want to use the
so-called "here document" feature that virtually any shell provides.
I.e., to append the above lines to 'somefile', you could write

cat >>somefile <<"ENDOFQUOTE"
export LS_OPTIONS='--color=auto'
eval `dircolors`
alias ls='ls $LS_OPTIONS -F'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
ENDOFQUOTE

See the section "Here Documents" in the bash manpage for details (such
as parameter expansion within the quoted text, etc.).

Cheers,
Almut


I was unclear. Sorry bout that. However, you hit the nail on the head! Looks like an execellant way to achieve what I was wanting to achieve! Can I give points in here for the winner. :)

--
Highest Regards,

Rodney Richison
RCR Computing
http://www.rcrnet.net
118 N. Broadway
Cleveland, OK  74020
918-358-1111



Reply to: