- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Insertion of line at start of a large file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:18 AM
04-17-2002 01:18 AM
Insertion of line at start of a large file
I have a large file (2Gb). It contains many records from start to finish.
I would like to know how to insert a header line at the top of the file without generating another 2Gb file as I would have to with :
echo 'header' > masterfile
cat datafile >> masterfile
(ie 2 x 2Gb files exits at this point)
rm datafile
(leaving 1 2Gb file with the header)
Any ideas - a line editor. Some syntax would be appreciated. Thanks
On a side issue - does anyone know the maximum file size of an hfs file system. I know that you can use -o largefiles on a VxFS. HFS though ?
Thanks again
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:25 AM
04-17-2002 01:25 AM
Re: Insertion of line at start of a large file
Create file with header info only then cat the two files together.
cat header orig > new
then mv newfile to orig.
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 01:27 AM
04-17-2002 01:27 AM
Re: Insertion of line at start of a large file
man merge...
Just thoughts
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 02:00 AM
04-17-2002 02:00 AM
Re: Insertion of line at start of a large file
Your question of HSF file sizes :-
http://docs.hp.com/hpux/onlinedocs/5971-2383/5971-2383.html
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 02:03 AM
04-17-2002 02:03 AM
Re: Insertion of line at start of a large file
http://docs.hp.com/hpux/onlinedocs/5971-2383/5971-2383.html
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 02:32 AM
04-17-2002 02:32 AM
Re: Insertion of line at start of a large file
Other aproach is:
Create a file called newfile with the new record, then do
cat oldfile >> newfile
Then if you want rename the file.
Another approach is using ed editor:
$ ed oldfile
0r newfile
w
q
$
you can use this with a file redirection, see ed man page.
Best regards,
Justo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 04:55 AM
04-17-2002 04:55 AM
Re: Insertion of line at start of a large file
You could try this:
cat - <
header line
.
w
q
EOF
This was a modification to the example from ed's man page.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 05:18 AM
04-17-2002 05:18 AM
Re: Insertion of line at start of a large file
Just tested my ed suggestion with a file that was too large to copy (filesystem would fill). It failed. In this case, ed created a temp file in the same directory that the source file was in. When the filesystem filled, the temp file was left in place. It didn't matter if I cd'ed to another filesystem or not.
Further testing found that a temp file was created even for a small input file. So I'm guessing that ed makes a copy of the file regardless of size which is the thing you didn't want to do.
Darrell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2002 06:28 AM
04-17-2002 06:28 AM
Re: Insertion of line at start of a large file
It probabily would be cheaper to buy extra disk space, but if you really want to do this then it will require some programming by doing binary reads/writes. In your favorite programming language do the following-
1) Append an empty block onto your file
2) read the last block of data and write it to the new empty block
3) read the next to the last block of data and write it to the block read in previous step
4) repeat until all blocks shuffled down, leaving the 1st block available for data.
5) insert your header into the 1st block
If anything goes wrong with this process your original file will of course be hosed.
If you really wanted to do it proper, you would have to take in account the length of the header line and shift down that much data in each block shuffled.
Good Luck
-- Rod Hills