Mailing List Archive


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

Re: [tlug] Adding text to the beginning of a file



On Sat, Mar 17, 2007 at 10:32:27AM +0900, Dave M G wrote:
> Arwyn,
> 
> 1. Can I use cat to prepend the contents of a variable in the shell script? I 
> tried this:
> TEXT="This is text"
> cat $TEXT temp.file >> new.file

Rather than cat I think you want echo for a variable.  
The cat command will echo the contents of a file

cat $TEXT (in zsh, behavior will be similar in others)
this is text no such file or directory.

echo $TEXT
this is text

echo $TEXT > file1; cat file1.

In your case, a very kludgy way to do it might be 
echo $TEXT > new.file; cat temp.file >> new.file

-- 

Scott Robbins

PGP keyID EB3467D6
( 1B48 077D 66F6 9DB0 FDC2 A409 FA54 EB34 67D6 )
gpg --keyserver pgp.mit.edu --recv-keys EB3467D6

Cordelia: Hi! You having fun?
Angel: Sure. This is, uh...
Cordelia: Your idea of hell.
Angel: Actually, in hell you tend to know a lot of the people


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links