- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sed 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
05-20-2003 06:31 AM
05-20-2003 06:31 AM
# ftp and remsh sources can use a full path:
# archive_path = "/pub/IUXarchives/B.11.00_32bitCDE.gz"
# The data for the "impacts" statements are found
# by running /opt/ignite/lbin/archive_impact
impacts = "/" 27Kb
impacts = "/.dt" 35Kb
impacts = "/etc" 1864Kb
impacts = "/export" 1Kb
impacts = "/home" 1Kb
impacts = "/opt" 74096Kb
impacts = "/sbin" 13449Kb
impacts = "/stand" 1Kb
impacts = "/tmp" 1Kb
impacts = "/users" 40Kb
impacts = "/usr" 225951Kb
impacts = "/var" 5705Kb
exrequisite += "golden image - 64 bit OS"
visible_if = can_run_32bit
and this is the entire 2nd file (called mou110.impact):
impacts = "/" 23Kb
impacts = "/.sw" 100Kb
impacts = "/dev" 14Kb
impacts = "/etc" 41366Kb
impacts = "/home" 8Kb
impacts = "/opt" 1246434Kb
impacts = "/sbin" 37158Kb
impacts = "/stand" 55954Kb
impacts = "/tmp" 6Kb
impacts = "/users" 1Kb
impacts = "/usr" 909819Kb
impacts = "/var" 542014Kb
I'm trying to replace all the "impact" entried in the first file with the entried in the second file. The reasone I am trying to replace the whole section is that the entried are not all the same....
i.e.
/.dt (original file)
/.sw (replacement file)
I'm in the process of scripting the creation of a bootable ingnite DVD (iso image)
Any help would be appreciated.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 06:40 AM
05-20-2003 06:40 AM
Re: sed script help
Replace all entries named "impacts" in the first file with contents of the second file? Is that the right interpretation?
Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 06:43 AM
05-20-2003 06:43 AM
Re: sed script help
sed -e '/^impacts/d' -e '/^# by running/r mou110.impact'
This will delete all "impacts" line from original and "r"ead the replacment file following the comment.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 06:44 AM
05-20-2003 06:44 AM
Re: sed script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 06:51 AM
05-20-2003 06:51 AM
Solutioncat /tmp/file1 |awk 'BEGIN {indic=0} $1 ~ /impact/ && indic == 0 {indic=1;rc=system("cat /tmp/impacts")}
indic == 1 && $1 !~ /impact/ {indic=2}
indic == 0 && $1 !~ /impact/ {print $0}
indic == 2 {print $0} ' >/tmp/newfile
Sample code, testing and works. /tmp/newfile = new output, /tmp/impacts = new list of impacts (no blank lines).
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 06:51 AM
05-20-2003 06:51 AM
Re: sed script help
#!/sbin/sh
TMP=$$
cat core11.cfg | grep -v impact > /tmp/$TMP.spool
cat /tmp/$TMP.spool > core11.cfg
cat mou110.impact >> core11.cfg
####EOF
Doing so you will have all the variable where you want.
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 06:52 AM
05-20-2003 06:52 AM
Re: sed script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 06:57 AM
05-20-2003 06:57 AM
Re: sed script help
using file1 file2 in,temp as work and file3 out
grep -v impacts file1 > temp
grep "#" temp > file3
cat file2 >> file3
grep -v "#" temp >> file3
rm temp
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 07:01 AM
05-20-2003 07:01 AM
Re: sed script help
sed -e '/^impacts/d' -e '/^# by running/r testf2'
and this is the results-
# ftp and remsh sources can use a full path:
# archive_path = "/pub/IUXarchives/B.11.00_32bitCDE.gz"
# The data for the "impacts" statements are found
# by running /opt/ignite/lbin/archive_impact
impacts = "/" 23Kb
impacts = "/.sw" 100Kb
impacts = "/dev" 14Kb
impacts = "/etc" 41366Kb
impacts = "/home" 8Kb
impacts = "/opt" 1246434Kb
impacts = "/sbin" 37158Kb
impacts = "/stand" 55954Kb
impacts = "/tmp" 6Kb
impacts = "/users" 1Kb
impacts = "/usr" 909819Kb
impacts = "/var" 542014Kb
exrequisite += "golden image - 64 bit OS"
visible_if = can_run_32bit
I had both testf1 and testf2 both under my current directory.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 07:04 AM
05-20-2003 07:04 AM
Re: sed script help
If you want to replace the original, then "mv" the resultant file to the original.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 07:05 AM
05-20-2003 07:05 AM
Re: sed script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 07:08 AM
05-20-2003 07:08 AM
Re: sed script help
Have just noticed the recursion within your sample file (2 sets of "impacts" lines).
Do we need to code around this, by either
a) replacing both sets of "impacts" lines, or
b) only replacing a specific set of "impacts" lines?
Have solutions to both; let us know if you need them, and which one.
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 07:12 AM
05-20-2003 07:12 AM
Re: sed script help
#!/usr/bin/ksh
file1=
file2=
tmpFile=
rm $tmpFile
cat file1 |
while read a b c size
do
start="$a $b $c"
case $start in
^${start}*)
size=$(grep "^$start" file2 | cut -f4)
;;
esac
print "$start $size" >> $tmpFile
done
haven't tested but should be pretty close to what your looking to do
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 07:12 AM
05-20-2003 07:12 AM
Re: sed script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 07:13 AM
05-20-2003 07:13 AM
Re: sed script help
This awk script could also do it ...
Regards.
awk '/^impact/ {if (flg != 1)
{
flg=1
system("cat mou110.impact")
}
next
}
{print}' core11.cfg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 07:15 AM
05-20-2003 07:15 AM
Re: sed script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 07:34 AM
05-20-2003 07:34 AM
Re: sed script help
cat /tmp/file1 |awk -vsubset="64 bit" 'BEGIN {indic=0;subsect=0}
$0 ~ "\}" {indic=0;subsect=0}
$0 ~ subset {subsect=1}
$1 ~ /impact/ && indic == 0 && subsect == 1 {indic=1;rc=system("cat /tmp/impacts")}
indic == 1 && $1 !~ /impact/ {indic=2}
indic == 0 && $1 ~ /impact/ && subsect != 1 {print $0}
indic == 0 && $1 !~ /impact/ {print $0}
indic == 2 {print $0} ' >/tmp/newfile
# First code - resets back to Zero everytime if finds a curly brace (does all occurences)
# cat /tmp/file1 |awk 'BEGIN {indic=0}
# $0 ~ "\{" || $0 ~ "\}" {indic=0}
# $1 ~ /impact/ && indic == 0 {indic=1;rc=system("cat /tmp/impacts")}
# indic == 1 && $1 !~ /impact/ {indic=2}
# indic == 0 && $1 !~ /impact/ {print $0}
# indic == 2 {print $0} ' >/tmp/newfile
Attached as a file. First piece of code is commented out so I could test the second. Both pieces tested on your sample, second part tested on keywords "32 bit" and "64 bit".
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2003 07:46 AM
05-20-2003 07:46 AM
Re: sed script help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 09:06 AM
06-02-2003 09:06 AM
Re: sed script help
It's been a while since you solved this problem... I was bored today and was looking over this ... I've never used this type of structure (indic) before and was wondering if you could explain it a little?
if not thanks for the solution....
catch a man a fish and you feed him for a day.... teach a man to fish and you feed him for a lifetime.