<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Quick scripting query in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863100#M821144</link>
    <description>&lt;BR /&gt;  Something like this&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# cd /tothedirwherefilesexists&lt;BR /&gt;# find . -type f -print &amp;gt; /tmp/1&lt;BR /&gt;# for fil in $(cat /tmp/1)&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; sed 's/\([a-z][a-z]*\)-mgt.domainx.com/\1.it.newdomain.net' &amp;gt; ${fil}.new&lt;BR /&gt;&amp;gt;done&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;now after testing ${fil}.new files rename them&lt;BR /&gt;&lt;BR /&gt;Sundar.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 13 Dec 2002 08:40:56 GMT</pubDate>
    <dc:creator>Sundar_7</dc:creator>
    <dc:date>2002-12-13T08:40:56Z</dc:date>
    <item>
      <title>Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863087#M821131</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I'm in the process of modifying a series of files in one particular directory.&lt;BR /&gt;&lt;BR /&gt;I have attached a copy of the file I need to modify.&lt;BR /&gt;&lt;BR /&gt;Our domain name has changed therefore need to change this in the files. I need to change the line towards the bottom which has the name of the host with it's fully qualified domain name.&lt;BR /&gt;&lt;BR /&gt;This line currently reads:&lt;BR /&gt;&lt;BR /&gt;HOST "dwnps006-mgt.domainx.com" dwnps006-mgt.domainx.com&lt;BR /&gt;&lt;BR /&gt;I need to change this to:&lt;BR /&gt;&lt;BR /&gt;HOST "dwnps006.it.newdomain.net" dwnps006.it.newdomain.net&lt;BR /&gt;&lt;BR /&gt;I need to do this for about 35-40 files. Obviously each host name is different. The name of the host is also in the first line of the file: (after Quotes and before underscore)&lt;BR /&gt;&lt;BR /&gt;DATALIST "dwnps006_system_adhoc"&lt;BR /&gt;&lt;BR /&gt;So first I will need to put hostname in a variable then use this and replace everything after HOST with:&lt;BR /&gt;&lt;BR /&gt;HOST "$hostname.it.newdomain.net" $hostname.it.newdomain.net&lt;BR /&gt;&lt;BR /&gt;I hope this is a straight forward problem. How would I put hostname into a variable so that I can use it to replace old FQDN with new one.&lt;BR /&gt;&lt;BR /&gt;Thanks, any help much appreciated.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Mohammed.</description>
      <pubDate>Thu, 12 Dec 2002 11:53:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863087#M821131</guid>
      <dc:creator>Mohammed Usman Ali</dc:creator>
      <dc:date>2002-12-12T11:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863088#M821132</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;hostname=yourhost&lt;BR /&gt;HOST "`$hostname`.it.newdomain.net" $hostname.it.newdomain.net &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;U.SivaKumar&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Dec 2002 12:02:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863088#M821132</guid>
      <dc:creator>U.SivaKumar_2</dc:creator>
      <dc:date>2002-12-12T12:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863089#M821133</link>
      <description>Seriously, for 30-45 files it would be faster AND safer using vi&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Thu, 12 Dec 2002 12:04:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863089#M821133</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-12-12T12:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863090#M821134</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;If domain part is constant.&lt;BR /&gt;&lt;BR /&gt;hostname=yourhostname.it.newdomain.net&lt;BR /&gt;HOST "$hostname" $hostname&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;U.SivaKumar&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Dec 2002 12:06:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863090#M821134</guid>
      <dc:creator>U.SivaKumar_2</dc:creator>
      <dc:date>2002-12-12T12:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863091#M821135</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Here's a little script.&lt;BR /&gt;&lt;BR /&gt;awk ' {&lt;BR /&gt;FS = "-"&lt;BR /&gt;printf "%s.it.newdomain.net\n", $1 } ' fileName.in&lt;BR /&gt;&lt;BR /&gt;Tom</description>
      <pubDate>Thu, 12 Dec 2002 12:15:41 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863091#M821135</guid>
      <dc:creator>Tom Jackson</dc:creator>
      <dc:date>2002-12-12T12:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863092#M821136</link>
      <description>&lt;BR /&gt;Here's a script:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;#&lt;BR /&gt;# PUT your 35-40 file names in /tmp/filelist&lt;BR /&gt;# BUT make sure you use the FULL PATH NAME&lt;BR /&gt;#&lt;BR /&gt;for fname in `cat /tmp/filelist`&lt;BR /&gt;do&lt;BR /&gt;cat $fname|eval `head -1 $fname|cut -d'"' -f2|cut -d'_' -f1|sed "s/.*/sed \"s_&amp;amp;-&lt;BR /&gt;mgt.domainx.com_&amp;amp;.it.newdomain.net_g\"/"`&amp;gt;${fname}TEMP&lt;BR /&gt;mv ${fname}TEMP $fname&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So /tmp/filelist would look like this:&lt;BR /&gt;&lt;BR /&gt;/somepath/somefile1&lt;BR /&gt;/somepath/somefile2&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry</description>
      <pubDate>Thu, 12 Dec 2002 12:28:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863092#M821136</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2002-12-12T12:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863093#M821137</link>
      <description>You you try:&lt;BR /&gt;&lt;BR /&gt;For i in file1 file2 file3 ...&lt;BR /&gt;do&lt;BR /&gt;cp $i $i.origcopy&lt;BR /&gt;sed "s/dwnps006-mgt.domainx.com/dwnps006.it.newdomain.net/g" $i &amp;gt; $i.tmpcopy&lt;BR /&gt;cp $i.tmpcopy $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Once you have done this you can check the files, if everything is messed up replace the .orig files.  Once you are sure everything is fine remove the .tmpcopy and .origcopy files.&lt;BR /&gt;&lt;BR /&gt;Kind regards,&lt;BR /&gt;&lt;BR /&gt;Robert Thorneycroft</description>
      <pubDate>Thu, 12 Dec 2002 12:36:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863093#M821137</guid>
      <dc:creator>Robert Thorneycroft</dc:creator>
      <dc:date>2002-12-12T12:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863094#M821138</link>
      <description>*Important*&lt;BR /&gt;In the above message sed and the next two lines are all part of the same line.&lt;BR /&gt;&lt;BR /&gt;Damn editor needs longer line lengths :(&lt;BR /&gt;&lt;BR /&gt;Regards.</description>
      <pubDate>Thu, 12 Dec 2002 12:39:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863094#M821138</guid>
      <dc:creator>Robert Thorneycroft</dc:creator>
      <dc:date>2002-12-12T12:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863095#M821139</link>
      <description>Hi Mohamed,&lt;BR /&gt;&lt;BR /&gt;an easy way to do so would be:&lt;BR /&gt;&lt;BR /&gt;1. create a file /tmp/filelist containing the list of files you want to update&lt;BR /&gt;&lt;BR /&gt;2. create then run this script:&lt;BR /&gt;&lt;BR /&gt;#! /usr/bin/ksh&lt;BR /&gt;for i in `cat /tmp/filelist`&lt;BR /&gt;do&lt;BR /&gt;sed 's/dwnps006-mgt.domainx.com/dwnps006.it.newdomain/g' $i &amp;gt; /tmp/tempfile&lt;BR /&gt;mv tmpfile $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;tested on your file&lt;BR /&gt;Hope this helps&lt;BR /&gt;&lt;BR /&gt;FiX&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Dec 2002 12:54:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863095#M821139</guid>
      <dc:creator>F. X. de Montgolfier</dc:creator>
      <dc:date>2002-12-12T12:54:51Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863096#M821140</link>
      <description>Thanks for the reply guys,&lt;BR /&gt;&lt;BR /&gt;The hostname dwnps006 is just in that one file. Every other file has a different hostname. This host name is at the top of the file after DATALIST " and before the _&lt;BR /&gt;&lt;BR /&gt;So Ideally I would want to cut the hostname put it in a variable and use that variable at the bottom of the file appending the new FQDN.&lt;BR /&gt;&lt;BR /&gt;By the way... I have to do this for 137 files in dir not 35-40 :)&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Mohammed.</description>
      <pubDate>Thu, 12 Dec 2002 15:26:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863096#M821140</guid>
      <dc:creator>Mohammed Usman Ali</dc:creator>
      <dc:date>2002-12-12T15:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863097#M821141</link>
      <description>Thanks Harry D Brown... I opted for your approach. However instead of cat directory I did for i in `ls directory`&lt;BR /&gt;&lt;BR /&gt;Thanks.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;Mohammed.</description>
      <pubDate>Thu, 12 Dec 2002 16:00:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863097#M821141</guid>
      <dc:creator>Mohammed Usman Ali</dc:creator>
      <dc:date>2002-12-12T16:00:12Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863098#M821142</link>
      <description>Hi Mohammed,&lt;BR /&gt;&lt;BR /&gt;I may miss something here, but this seems to a very simple task&lt;BR /&gt;like&lt;BR /&gt;&lt;BR /&gt;perl -i.bak  -npe 's/domainx\.com/newdoain\.net/g'  filelist&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;where filelist are the 1000 files you need to change.&lt;BR /&gt;Perl's in-place option saves us a backup copy of with the extension .bak in my example of each file, and writes changes to your original files.&lt;BR /&gt;&lt;BR /&gt;If you don't want to specify your filelist use shell globbing or command subtitution from an ls or supply a file with the list</description>
      <pubDate>Thu, 12 Dec 2002 16:11:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863098#M821142</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2002-12-12T16:11:52Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863099#M821143</link>
      <description>Re Hi Mohamed,&lt;BR /&gt;&lt;BR /&gt;I didn't realise the hostname var a parameter...&lt;BR /&gt;&lt;BR /&gt;Will this be what you wanted?&lt;BR /&gt;&lt;BR /&gt;same process as before, put all file names in /tmp/filelist&lt;BR /&gt;&lt;BR /&gt;The shell script becomes:&lt;BR /&gt;&lt;BR /&gt;#! /usr/bin/ksh&lt;BR /&gt;for i in `cat /tmp/filelist`&lt;BR /&gt;do&lt;BR /&gt;host_name=`grep DATALIST test|sed 's/.*DATALIST \"//'|sed 's/_.*//'`&lt;BR /&gt;&lt;BR /&gt;sed 's/"${host_name}"-mgt.domainx.com/"${host_name}".it.newdomain/g' $i &amp;gt; /tmp/tmpfile&lt;BR /&gt;mv tmpfile $i&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Would this be what you're looking for? I know the host_name calculation is not very pretty, but it works ;-)&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;FiX&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 12 Dec 2002 16:42:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863099#M821143</guid>
      <dc:creator>F. X. de Montgolfier</dc:creator>
      <dc:date>2002-12-12T16:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863100#M821144</link>
      <description>&lt;BR /&gt;  Something like this&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# cd /tothedirwherefilesexists&lt;BR /&gt;# find . -type f -print &amp;gt; /tmp/1&lt;BR /&gt;# for fil in $(cat /tmp/1)&lt;BR /&gt;&amp;gt; do&lt;BR /&gt;&amp;gt; sed 's/\([a-z][a-z]*\)-mgt.domainx.com/\1.it.newdomain.net' &amp;gt; ${fil}.new&lt;BR /&gt;&amp;gt;done&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;now after testing ${fil}.new files rename them&lt;BR /&gt;&lt;BR /&gt;Sundar.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 13 Dec 2002 08:40:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863100#M821144</guid>
      <dc:creator>Sundar_7</dc:creator>
      <dc:date>2002-12-13T08:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: Quick scripting query</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863101#M821145</link>
      <description>I have attached a script for you.  I believe this will solve your dilemma.  It includes two scripts. Just delete what you don't want. The first one somply changes the domain. The second looks at the host name but I do not think you need to worry about the host names since you are only changing the domain, but I stuck it in there anyway. &lt;BR /&gt;</description>
      <pubDate>Fri, 13 Dec 2002 14:53:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/quick-scripting-query/m-p/2863101#M821145</guid>
      <dc:creator>Thomas M. Williams_1</dc:creator>
      <dc:date>2002-12-13T14:53:08Z</dc:date>
    </item>
  </channel>
</rss>

