Appending to the first line of a document

Hi all, I'm new to the forums and a total beginner with Unix. I've been given the seemingly simple task of writing a script that asks for two arguments: the first argument being a line of text, the second argument being a document. The script has to take the first argument of text and append it to the specified document in the second argument (no problem), but then the text must be appended to the first line of the document (without using SED or AWK) and I'm confused as to what command I use to do this.

I thought one way around this would be to CAT the first arg and then the second, then save the output to the file noted in the second arg, but because the input and output sources are the same in the second arg, shell doesnt want to know. I have a feeling there is something so simple that I'm missing, but going back over my notes, I can't seem to find what it is that I should know here? Any thoughts?

Perhaps there some way to run VI or EX commands from the shell so that I can paste the input from the first arg into the specified document?

Would really appreciate some advice here! Many thanks.

here's the advice

Thanks...but what should I be looking at here?

Sorry, but "no awk or sed" is obviously a homework assignment. I hate being a stickler for rules, but there's a rule on this board saying don't post such questions. It's for the sake of (a) your fellow students, and (b) others on here who are professionals and need this board for their work. Or something like that.

Having said that, what happens with the following code?

( cat file.txt; echo "Middle Line"; cat file.txt; ) >output.txt

Sorry otheus, I didn't realise. Thanks for the tip anyhow, I'll give it a try.

Hi,

I am not sure whether i understood your repuirements totally.
If so, below should be ok for you.

code(c.sh):

echo $1 > temp
cat $2 >> temp

test file(a.txt):

This is the second line.
This is the third line.

command:

c.sh "This is the first line" a.txt

result:

This is the first line
This is the second line.
This is the third line.