I am looking for the most efficient way in a script to add the
contents of a 4 line file to the top of another much larger file. It
would be good to avoid the I-O of doing a cat of the large file to the
end of the small file.
Any ideas?
Any ideas?
I think any way to put the small file in the beginning the big one willQuote:> I am looking for the most efficient way in a script to add the
> contents of a 4 line file to the top of another much larger file. It
> would be good to avoid the I-O of doing a cat of the large file to the
> end of the small file.
> Any ideas?
--
Stanislaw Klekot
> > Any ideas?
> I think any way to put the small file in the beginning the big one will
> end up with writting the big one after small one, so cat is IMO as good
> way to do it as any other. If you want to avoid such operation try to
> change something before creating that big file.
$ mv big scratch
$ mv small big
$ cat scratch >> big
Walt R.
**
> > > Any ideas?
sed -e 'Quote:> **
> Awk or sed might be able to do that, but I do not know how.
note: in case your large file contains just 1 line then the above
won't work. In fact, 'sed' cannot accomplish this :-(.
We can then do it in a 2-pass way as:
sed -e '
1{
r add
$n
N
' Large_file | \Quote:}
> Any ideas?
(the "> " is PS2 prompt, not literally entered)Quote:> w
> q' | ed big_file
This, however, doesn't necessarily avoid the I/O.
1. Adding text to the top of a file without using temporary files
I want to send a text file via "mail". Before I pass the file to mail, I want
to insert at the top of the file a subject line of "Subject: < report name>".
I would dearly like to do this without using temporary files, etc. but I can't
find a way of doing it. I've tried echoing text through pipes, cating the
mail file various ways to try and prefix it with the subject line. I've looked
at sed but, not being a sed expert, I haven't found a solution that way either.
Before anyone asks, there isn't a switch to pass the subject to the mail
command. 8-(
Does anyone know of a one line solution to do this without the creation of
temporary files?
Thanks
Andrew Scott.
=====
Development Centre, IS.
AT&T Global Information Solutions,
Kingsway West, Dundee, Scotland DD2 3XX
Tel: +44 382 592531 Fax: +44 382 622198
2. LS-120
3. adding lines to the top of a file??
4. start up redhat on the dell server
5. Appending a file into a top of a file.
7. getting rid of top lines of a file without searching through entire file
9. How to add files into a tar file
10. Restore (file by file) and many named files
11. vi: file.clear==>file.encrypt==>file.clear ?
12. where are files to convert ez files to ps files for printing?
13. "Standard Journaled File System" vs "Large File Enabled Journaled File System"