- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script help
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
07-19-2001 09:40 AM
07-19-2001 09:40 AM
Script help
I need help with a script that I want to add a line to an existing file in a certain spot. For instance, take the following file:
NAME "server_DLT"
DESCRIPTION "server_DLT"
HOST server.com
POLICY Standalone
TYPE DLT
POOL "server_DLT"
CLEANME
DRIVES
"/dev/rmt1"
and change it to:
NAME "server_DLT"
DESCRIPTION "server_DLT"
HOST server.com
POLICY Standalone
TYPE DLT
POOL "server_DLT"
EJECT
CLEANME
DRIVES
"/dev/rmt1"
i.e. add the EJECT line after the POOL line. Any help would be greatly appreciated.
Thanks in advance,
Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2001 10:07 AM
07-19-2001 10:07 AM
Re: Script help
This works for me, assuming that there is only one keyword POOL. Also, be warned, everytime you run this it will keep adding the word EJECT after POOL.
#!/bin/sh
ed filename <
a
EJECT
.
w
q
STOPHERE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2001 10:09 AM
07-19-2001 10:09 AM
Re: Script help
perl -n -i -e 'print $_; print "EJECT\n" if /^POOL/' yourscriptfile
This will process the file and add EJECT after the line beginning with POOL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2001 10:11 AM
07-19-2001 10:11 AM
Re: Script help
sed '/CLEANME/iEJECT' copyoffile > filename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2001 10:13 AM
07-19-2001 10:13 AM
Re: Script help
There should be a backslash after the /i
and CHANGE should be on the next line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2001 12:19 PM
07-19-2001 12:19 PM
Re: Script help
Here's how I would do this:
#!/usr/bin/sh
echo "/POOL/a\\\\\nEJECT" > /tmp/sed.cmd
sed -f /tmp/sed.cmd /tmp/inp > /tmp/out
mv /tmp/out /tmp/inp
#.end.
The echo creates a sed script (command) file that looks like this:
/POOL/aEJECT
The 'a' says "append" after the match is made with "POOL".
Regards!
...JRF...