![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Reading the header of a tar file(posix header) | Tanvirk | Linux | 2 | 01-31-2008 08:50 AM |
| existing file to a fixed length file | cmanand | Shell Programming and Scripting | 3 | 01-25-2008 05:50 PM |
| adding existing disks to a 3510 array | malcqv | SUN Solaris | 2 | 12-21-2007 04:40 AM |
| SMF - Adding instances to existing manifest | craigp84 | SUN Solaris | 2 | 10-01-2007 06:55 AM |
| i want to delete a file based on existing file in a directory | srivsn | Shell Programming and Scripting | 3 | 04-11-2006 04:38 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Adding header to an existing file
Dear All,
I need to add a header of one line to an already existing file. I know that it can be achieved by the following: echo "Header" > newfile cat file1 >> newfile But my problem is that file is huge and there is no space for creating a new file every time. Is there a way that I can add header without creating a new file? Thanks Shash |
|
||||
|
If this is something you will need to do repeatedly, I suppose you could try something with an ex script. If you had something like this in a file named addhdr:
Code:
1i this is what my header will be . x Code:
ex - myreallybigfile < addhdr |
|
||||
|
Ok, so your file is too large. We need to use a "large file" safe editor. Switch from ex to ed and modify the end of the command file.
File addhdr_ed Code:
1i this is the 1st line of the header this is the 2nd line of the header (if needed) . w q Code:
ed - myreallylargefile < addhdr_ed |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|