<?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: parsing shell variable to vi in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075059#M141489</link>
    <description>or maybe with awk ?&lt;BR /&gt;&lt;BR /&gt;here's a skeletton script :)&lt;BR /&gt;&lt;BR /&gt;awk -F":" '$1 ~ /USERNAME/ { print "X" $1 ":*AP*:" $3 } $1 !~ /USERNAME/ { print }' /etc/passwd&lt;BR /&gt;&lt;BR /&gt;my example will only change the first 3 fields, but you get the idea - if first field matches you do all changes you want in there with print $field and if it does not match then you just print the line untouched. this produces an updated passwd file.</description>
    <pubDate>Fri, 19 Sep 2003 12:05:58 GMT</pubDate>
    <dc:creator>Patrick Van Humbeeck</dc:creator>
    <dc:date>2003-09-19T12:05:58Z</dc:date>
    <item>
      <title>parsing shell variable to vi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075053#M141483</link>
      <description>is there any way to parse a variable defined in shell and use in vi editor or reference it usng $user .</description>
      <pubDate>Fri, 19 Sep 2003 08:45:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075053#M141483</guid>
      <dc:creator>mahesh_24</dc:creator>
      <dc:date>2003-09-19T08:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: parsing shell variable to vi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075054#M141484</link>
      <description>Mahesh,&lt;BR /&gt;  I am not able to understand your question correctly.  Explain the question a little bit.&lt;BR /&gt;&lt;BR /&gt;  Why do you want to use a variable in a vi editor?  How?&lt;BR /&gt;&lt;BR /&gt;-Umapathy</description>
      <pubDate>Fri, 19 Sep 2003 09:12:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075054#M141484</guid>
      <dc:creator>Umapathy S</dc:creator>
      <dc:date>2003-09-19T09:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: parsing shell variable to vi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075055#M141485</link>
      <description>i am supplying one variable in the shell script as input , now i want to use the same variable in vi.search the pattern using that variable value and replace that with the new variable.</description>
      <pubDate>Fri, 19 Sep 2003 10:25:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075055#M141485</guid>
      <dc:creator>mahesh_24</dc:creator>
      <dc:date>2003-09-19T10:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: parsing shell variable to vi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075056#M141486</link>
      <description>mahesh,&lt;BR /&gt;&lt;BR /&gt;I think you need to look at "sed".  I have to admit, the man page for sed puts people off for a year or two before they start using it but a simple use might help you here.&lt;BR /&gt;&lt;BR /&gt;sed "s/pattern/$variable/g" will look for all occurances of the pattern and replace it with the value of the variable.  sed can be given a file name to look through for this pattern or it can take its standard input.</description>
      <pubDate>Fri, 19 Sep 2003 10:29:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075056#M141486</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-09-19T10:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: parsing shell variable to vi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075057#M141487</link>
      <description>Hi Mark, &lt;BR /&gt;i have  used sed to perform some of my task.&lt;BR /&gt;&lt;BR /&gt;the requirement is to disable a user from the passwd file and the fields to be changed are &lt;BR /&gt;&lt;BR /&gt;passwd filed to *AP*&lt;BR /&gt;username to Xusername&lt;BR /&gt;GECOS field to "disabled"&lt;BR /&gt;shell to /bin/false&lt;BR /&gt;&lt;BR /&gt;now i have written some code using sed , i am pasting below but changes only the user field&lt;BR /&gt;&lt;BR /&gt;sed -n    '/^'$user1':/ {&lt;BR /&gt;             s/'$user1'/X'$user1'/&lt;BR /&gt;             p&lt;BR /&gt;             }' passwd.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;any help will be highly apprecialted.</description>
      <pubDate>Fri, 19 Sep 2003 11:50:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075057#M141487</guid>
      <dc:creator>mahesh_24</dc:creator>
      <dc:date>2003-09-19T11:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: parsing shell variable to vi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075058#M141488</link>
      <description>Sometimes it's just better to go with perl&lt;BR /&gt;&lt;BR /&gt;Here is a easy to read perl script.&lt;BR /&gt;&lt;BR /&gt;It takes an argument of the user name you want to change and writes it to the standard output.  &lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;&lt;BR /&gt;open INPUTFILE,"&lt;BR /&gt;while($line=&lt;INPUTFILE&gt;){&lt;BR /&gt;        chomp($line);&lt;BR /&gt;        ($login,$passwd,$uid,$gid,$gecos,$homedir,$sh)=split ":",$line;&lt;BR /&gt;        if($login eq $ARGV[0]){&lt;BR /&gt;                $login="X$login";&lt;BR /&gt;                $passwd="*AP*";&lt;BR /&gt;                $gecos="disabled";&lt;BR /&gt;                $sh="/bin/false";&lt;BR /&gt;        }&lt;BR /&gt;        print "$login:$passwd:$uid:$gid:$gecos:$homedir:$sh\n";&lt;BR /&gt;}&lt;BR /&gt;&lt;/INPUTFILE&gt;</description>
      <pubDate>Fri, 19 Sep 2003 12:03:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075058#M141488</guid>
      <dc:creator>Mark Grant</dc:creator>
      <dc:date>2003-09-19T12:03:17Z</dc:date>
    </item>
    <item>
      <title>Re: parsing shell variable to vi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075059#M141489</link>
      <description>or maybe with awk ?&lt;BR /&gt;&lt;BR /&gt;here's a skeletton script :)&lt;BR /&gt;&lt;BR /&gt;awk -F":" '$1 ~ /USERNAME/ { print "X" $1 ":*AP*:" $3 } $1 !~ /USERNAME/ { print }' /etc/passwd&lt;BR /&gt;&lt;BR /&gt;my example will only change the first 3 fields, but you get the idea - if first field matches you do all changes you want in there with print $field and if it does not match then you just print the line untouched. this produces an updated passwd file.</description>
      <pubDate>Fri, 19 Sep 2003 12:05:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075059#M141489</guid>
      <dc:creator>Patrick Van Humbeeck</dc:creator>
      <dc:date>2003-09-19T12:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: parsing shell variable to vi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075060#M141490</link>
      <description>Thanks Partrik But here there something needs to be done as eg the user name here is 'oracle" so by using the above commands it will match users like "oracledb" oracledba etc .</description>
      <pubDate>Mon, 22 Sep 2003 23:31:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075060#M141490</guid>
      <dc:creator>mahesh_24</dc:creator>
      <dc:date>2003-09-22T23:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: parsing shell variable to vi</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075061#M141491</link>
      <description>mahesh,&lt;BR /&gt;&lt;BR /&gt;you can solve this problem easily by matching $1 ~ /^USERNAME$/ instead of /USERNAME/.&lt;BR /&gt;&lt;BR /&gt;Rgds,&lt;BR /&gt;&lt;BR /&gt;Patrick</description>
      <pubDate>Tue, 23 Sep 2003 00:09:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/parsing-shell-variable-to-vi/m-p/3075061#M141491</guid>
      <dc:creator>Patrick Van Humbeeck</dc:creator>
      <dc:date>2003-09-23T00:09:09Z</dc:date>
    </item>
  </channel>
</rss>

