<?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: Problem replacing text in a script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858884#M95600</link>
    <description>Hi,&lt;BR /&gt;&lt;BR /&gt;bdf gives you the name of the lv your application is using.&lt;BR /&gt;&lt;BR /&gt;I prefer using bdf &lt;APP dir=""&gt; to grepping it from fstab, as it will give you the logical volume the application is installed on even if it is sharing its logical volume...&lt;BR /&gt;&lt;BR /&gt;#[SAVE]&amp;gt; bdf /tmp/test/&lt;BR /&gt;Filesystem kbytes used avail %used Mounted on&lt;BR /&gt;/dev/vg00/lvol4 1024000 40785 921815 4%  /tmp&lt;BR /&gt;&lt;BR /&gt;The following command should, (though there might be tyops: I don't have access to my system fron here), give you the correct answer:&lt;BR /&gt;&lt;BR /&gt;bdf $APPHOME |grep /dev/ |sed 's!(\^[^ ]+/\)!\1r!'|awk '{print $1}'&lt;BR /&gt;&lt;BR /&gt;The bdf part will give you the logical volume on which your application resides, the grep will ensure that only the relevant line is printed, the sed will find the longest string containing a '/' since the begining of the line, and add 'r'after it, and the awk will print only the first argument...&lt;BR /&gt;&lt;BR /&gt;I won't promise that the command is _fast_, though ;-)&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Fran??ois-Xavier&lt;BR /&gt;&lt;/APP&gt;</description>
    <pubDate>Mon, 09 Dec 2002 13:50:15 GMT</pubDate>
    <dc:creator>F. X. de Montgolfier</dc:creator>
    <dc:date>2002-12-09T13:50:15Z</dc:date>
    <item>
      <title>Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858879#M95595</link>
      <description>I am trying to write a script that gets the value of the logival volume an application is on and then adds an r after the volume group so that I can run fsadm on it.&lt;BR /&gt; Somthing along the lines of cat /etc/fstab |grep $APPHOME |awk '{ print $1 }' sed ?????&lt;BR /&gt;&lt;BR /&gt;How would I insert the "r" into /dev/vg01/lvol6, sometimes clients use different naming conventions ... /dev/vg02/appname&lt;BR /&gt;&lt;BR /&gt;Thanks!</description>
      <pubDate>Thu, 05 Dec 2002 23:00:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858879#M95595</guid>
      <dc:creator>Gus Mestousis</dc:creator>
      <dc:date>2002-12-05T23:00:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858880#M95596</link>
      <description>I would do the following quickly -&lt;BR /&gt;&lt;BR /&gt;....&lt;BR /&gt;...&lt;BR /&gt;for ENTRY in $(grep $APPHOME /etc/fstab|awk '{print $1}') &lt;BR /&gt;do                                                        &lt;BR /&gt;LVOL=$(echo $ENTRY|awk '{FS="/";print $4}')               &lt;BR /&gt;RLVOL=$(echo $ENTRY|sed 's/'$LVOL'/r'$LVOL'/')            &lt;BR /&gt;echo $RLVOL                                               &lt;BR /&gt;done                                                      &lt;BR /&gt;&lt;BR /&gt;-Sri&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Dec 2002 23:09:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858880#M95596</guid>
      <dc:creator>Sridhar Bhaskarla</dc:creator>
      <dc:date>2002-12-05T23:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858881#M95597</link>
      <description>Other simple one would be &lt;BR /&gt;LVOL=`cat /etc/fstab|grep $APPHOME|awk -F / '{print $4}'`&lt;BR /&gt;VG=`cat /etc/fstab|grep $APPHOME|awk -F / '{print $3}'`&lt;BR /&gt;&lt;BR /&gt;And when you want to substitute with 'r' you can do it&lt;BR /&gt;&lt;BR /&gt;RLVOL=/dev/${VG}/r${LVOL}&lt;BR /&gt;&lt;BR /&gt;cheers&lt;BR /&gt;Rajeev</description>
      <pubDate>Thu, 05 Dec 2002 23:48:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858881#M95597</guid>
      <dc:creator>Rajeev  Shukla</dc:creator>
      <dc:date>2002-12-05T23:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858882#M95598</link>
      <description>Hi Gus,&lt;BR /&gt;&lt;BR /&gt;you could use the korn shell's built-in functions for string handling, e.g.:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;APPHOME=$1&lt;BR /&gt;&lt;BR /&gt;cat /etc/fstab | grep $APPHOME | while read line&lt;BR /&gt;do&lt;BR /&gt;        LVOL=`echo $line | awk '{print $1}'`&lt;BR /&gt;        ENDING=`basename $LVOL`&lt;BR /&gt;        BEGINNING="${LVOL%%$ENDING}"&lt;BR /&gt;        echo ${BEGINNING}r${ENDING}&lt;BR /&gt;done&lt;BR /&gt;~&lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Dec 2002 08:37:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858882#M95598</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2002-12-06T08:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858883#M95599</link>
      <description>Hi Gus,&lt;BR /&gt;&lt;BR /&gt;grep $APPHOME /etc/fstab | awk '{print $1}' | sed 's+.*/+&amp;amp;r+'&lt;BR /&gt;&lt;BR /&gt;Rgds, Robin</description>
      <pubDate>Fri, 06 Dec 2002 08:47:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858883#M95599</guid>
      <dc:creator>Robin Wakefield</dc:creator>
      <dc:date>2002-12-06T08:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858884#M95600</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;bdf gives you the name of the lv your application is using.&lt;BR /&gt;&lt;BR /&gt;I prefer using bdf &lt;APP dir=""&gt; to grepping it from fstab, as it will give you the logical volume the application is installed on even if it is sharing its logical volume...&lt;BR /&gt;&lt;BR /&gt;#[SAVE]&amp;gt; bdf /tmp/test/&lt;BR /&gt;Filesystem kbytes used avail %used Mounted on&lt;BR /&gt;/dev/vg00/lvol4 1024000 40785 921815 4%  /tmp&lt;BR /&gt;&lt;BR /&gt;The following command should, (though there might be tyops: I don't have access to my system fron here), give you the correct answer:&lt;BR /&gt;&lt;BR /&gt;bdf $APPHOME |grep /dev/ |sed 's!(\^[^ ]+/\)!\1r!'|awk '{print $1}'&lt;BR /&gt;&lt;BR /&gt;The bdf part will give you the logical volume on which your application resides, the grep will ensure that only the relevant line is printed, the sed will find the longest string containing a '/' since the begining of the line, and add 'r'after it, and the awk will print only the first argument...&lt;BR /&gt;&lt;BR /&gt;I won't promise that the command is _fast_, though ;-)&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Fran??ois-Xavier&lt;BR /&gt;&lt;/APP&gt;</description>
      <pubDate>Mon, 09 Dec 2002 13:50:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858884#M95600</guid>
      <dc:creator>F. X. de Montgolfier</dc:creator>
      <dc:date>2002-12-09T13:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858885#M95601</link>
      <description>a5:/ 108 # grep -v nfs /etc/fstab&lt;BR /&gt;/dev/vg00/lvol3 /               vxfs    delaylog 0 1&lt;BR /&gt;/dev/vg00/lvol1 /stand          hfs     defaults 0 1&lt;BR /&gt;/dev/vg00/tmp   /tmp            vxfs    rw,suid,largefiles,delaylog,datainlog 0 2&lt;BR /&gt;/dev/vg00/lvol7 /usr            vxfs    delaylog 0 2&lt;BR /&gt;/dev/vg00/var   /var            vxfs    delaylog 0 2&lt;BR /&gt;/dev/vg00/opt   /opt            vxfs    delaylog 0 2&lt;BR /&gt;/dev/vg00/home  /home           vxfs    delaylog 0 2&lt;BR /&gt;/dev/vg00/u     /u              vxfs    rw,suid,largefiles,delaylog,datainlog 0 2&lt;BR /&gt;/dev/vg00/pro   /pro            vxfs    rw,suid,largefiles,delaylog,datainlog 0 2&lt;BR /&gt;/dev/vg00/data  /data           vxfs    rw,suid,largefiles,delaylog,datainlog 0 2&lt;BR /&gt;/dev/vg00/wrk   /wrk            vxfs    rw,suid,largefiles,delaylog,datainlog 0 2&lt;BR /&gt;/dev/cd0        /cdrom          cdfs    ro,rr,noauto    0 0&lt;BR /&gt;a5:/ 109 # echo $APPHOME&lt;BR /&gt;/pro&lt;BR /&gt;a5:/ 110 # perl -nle'/$ENV{APPHOME}/&amp;amp;&amp;amp;s:\s.*::&amp;amp;&amp;amp;s:vg\d+/:$&amp;amp;r:&amp;amp;&amp;amp;print' /etc/fstab&lt;BR /&gt;/dev/vg00/rpro&lt;BR /&gt;a5:/ 111 #</description>
      <pubDate>Mon, 09 Dec 2002 14:01:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858885#M95601</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-12-09T14:01:59Z</dc:date>
    </item>
    <item>
      <title>Re: Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858886#M95602</link>
      <description>Sorry, following up on myself...&lt;BR /&gt;&lt;BR /&gt;I don't know why I insisted on using awk when sed is enough for the job...&lt;BR /&gt;Let's try doing it right this time:&lt;BR /&gt;&lt;BR /&gt;bdf $APPHOME |grep /dev/ |sed 's!(\^[^ ]+/\)(\[^ ]+\).+!\1r\2!'&lt;BR /&gt;&lt;BR /&gt;-  ^[^ ]+/ should give you the basename of your logical volume,&lt;BR /&gt;-  [^ ]+ should give you the logical volume name,&lt;BR /&gt;-  the .+ is there to engulf all the rest of the line&lt;BR /&gt;&lt;BR /&gt;Please remember that this is untested, as I don't have access to my platform. It should be near the mark, though...&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;&lt;BR /&gt;Fran??ois-Xavier&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Dec 2002 14:04:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858886#M95602</guid>
      <dc:creator>F. X. de Montgolfier</dc:creator>
      <dc:date>2002-12-09T14:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858887#M95603</link>
      <description>Thanks for all the great replies.&lt;BR /&gt;&lt;BR /&gt;Enjoy your holidays!&lt;BR /&gt;&lt;BR /&gt;Gus&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Dec 2002 14:13:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858887#M95603</guid>
      <dc:creator>Gus Mestousis</dc:creator>
      <dc:date>2002-12-09T14:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858888#M95604</link>
      <description>Attached is a perl script that handles this based on creating filelists.  Be careful using it on /etc files,but it works, is easy to modify and understand.&lt;BR /&gt;&lt;BR /&gt;It actually uses sed btw.&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Mon, 09 Dec 2002 17:16:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858888#M95604</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2002-12-09T17:16:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem replacing text in a script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858889#M95605</link>
      <description>Ahhhhhhrgggggg, someone still using perl4!&lt;BR /&gt;&lt;BR /&gt;Never use this, not even as an example.&lt;BR /&gt;And *if* you need using perl4, at least add -w to the command line.&lt;BR /&gt;&lt;BR /&gt;When converting this to perl5, start with something like&lt;BR /&gt;&lt;BR /&gt;#!/usr/local/bin/perl&lt;BR /&gt;&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;use File::Find;&lt;BR /&gt;use Sys::Hostname;&lt;BR /&gt;&lt;BR /&gt;:&lt;BR /&gt;:&lt;BR /&gt;:</description>
      <pubDate>Mon, 09 Dec 2002 17:24:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-replacing-text-in-a-script/m-p/2858889#M95605</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2002-12-09T17:24:06Z</dc:date>
    </item>
  </channel>
</rss>

