- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell script: put some text in the first line
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
Discussions
Discussions
Forums
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
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
тАО03-25-2003 07:51 AM
тАО03-25-2003 07:51 AM
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2003 07:54 AM
тАО03-25-2003 07:54 AM
Re: Shell script: put some text in the first line
echo "text" > file.new
cat file >> file.new
mv file.new file
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2003 08:05 AM
тАО03-25-2003 08:05 AM
Re: Shell script: put some text in the first line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2003 08:05 AM
тАО03-25-2003 08:05 AM
Re: Shell script: put some text in the first line
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2003 08:25 AM
тАО03-25-2003 08:25 AM
Re: Shell script: put some text in the first line
Try this:
# echo "new first line text here" | cat - yourfile | tee yourfile
Hai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2003 08:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2003 08:39 AM
тАО03-25-2003 08:39 AM
Re: Shell script: put some text in the first line
I like Hai Nguyen's answer.
Everyone gets points!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2003 08:40 AM
тАО03-25-2003 08:40 AM
Re: Shell script: put some text in the first line
If you like:
# awk 'BEGIN{print "INSERTED_TEXT!"};{print $0}' filename > filename.new
# mv filename.new filename
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2003 08:45 AM
тАО03-25-2003 08:45 AM
Re: Shell script: put some text in the first line
If you're not familiar with vi, here's a quick primer:
vi filename
O (thats capital "O", not zero) to "open" the first line.
Type your text.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-25-2003 08:54 AM
тАО03-25-2003 08:54 AM
Re: Shell script: put some text in the first line
you can use sed, awk, ex. to do this.
mv file.tmp file
use a for appending text
i for insert text at the begining
s for subtitution, or changes somewhere in the middle