- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Insert at top of 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
06-06-2001 05:00 AM
06-06-2001 05:00 AM
Insert at top of file?
Is there a way to redirect output to the top of a file, like >> but to go to top, without removing the file, inserting, then appending the old contents?
Any suggestions?
Thanks
Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 05:03 AM
06-06-2001 05:03 AM
Re: Insert at top of file?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 05:15 AM
06-06-2001 05:15 AM
Re: Insert at top of file?
cat file1 file2 > file3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 05:17 AM
06-06-2001 05:17 AM
Re: Insert at top of file?
i.e copy file to appfile
then newfile >> appfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 05:20 AM
06-06-2001 05:20 AM
Re: Insert at top of file?
firstline
secondline
thirdline
I would like to redirect the output of a command to the top of this file resulting in
textoutput
firstline
secondline
thirdline
Thanks
Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 05:22 AM
06-06-2001 05:22 AM
Re: Insert at top of file?
to achieve what you want, you must have an intervening/temporary files eg.:
echo $STRING > /tmp/prepend ; cat /tmp/prepend $YOURFILE > /tmp/finalfile ; mv /tmp/finalfile $YOURFILE ; rm /tmp/prepend
you could actually alias the above string (or some other incarnation of it)
good luck
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 05:22 AM
06-06-2001 05:22 AM
Re: Insert at top of file?
I don?t remember, but maybe this its possible
whith ed command.
I hope this helps
Abel Berger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2001 05:23 AM
06-06-2001 05:23 AM
Re: Insert at top of file?
If you have file1:
firstline
secondline
thirdline
redirect the output of a command to a file
output > file2
and then:
cat file2 file1 > file3
you'll see in file3:
textoutput
firstline
secondline
thirdline
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2001 06:23 AM
06-07-2001 06:23 AM
Re: Insert at top of file?
Here's another simple way
logFile.new contains:
firstLine
secondLine
thirdLine
One way could be :
mv logFile.new logFile.old
yourcommand > logFile.new | cat logFile.old >> logFile.new
logFile.new now contains:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2001 07:14 AM
06-07-2001 07:14 AM
Re: Insert at top of file?
ex -s yourfile <
wq
EOF