<?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: use of VI editor in script in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959671#M101021</link>
    <description>I feel JRF is shown the best. :)&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;oldfile=abc&lt;BR /&gt;newfile=$(head -1 ${oldfile})&lt;BR /&gt;perl -ne 'print if ($. != 1)' ${oldfile} &amp;gt; ${newfile}&lt;BR /&gt;rm -f ${oldfile}&lt;BR /&gt;&lt;BR /&gt;# END&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu</description>
    <pubDate>Tue, 14 Feb 2006 08:09:30 GMT</pubDate>
    <dc:creator>Muthukumar_5</dc:creator>
    <dc:date>2006-02-14T08:09:30Z</dc:date>
    <item>
      <title>use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959661#M101011</link>
      <description>Hi All,&lt;BR /&gt;I want to write a script where I need to read one file. First line contains one name and rest of the lines contains data. I need to read that name, rename this file with that name and delete that first line from the file.&lt;BR /&gt;Eg. cat abc&lt;BR /&gt;xyz &lt;BR /&gt;123&lt;BR /&gt;12123&lt;BR /&gt;2q32&lt;BR /&gt; &lt;BR /&gt;Now I need to rename abc to xyz and delete first line "xyz" from abc and save the file as xyz.</description>
      <pubDate>Tue, 14 Feb 2006 06:39:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959661#M101011</guid>
      <dc:creator>yogesh_4</dc:creator>
      <dc:date>2006-02-14T06:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959662#M101012</link>
      <description>Use this:&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;oldfile=abc&lt;BR /&gt;newfile=$(sed -e '1!d' ${oldfile})&lt;BR /&gt;count=$(wc -l ${oldfile} | awk '{ print $1 }')&lt;BR /&gt;&lt;BR /&gt;sed -e '2,${count}!d' ${oldfile} &amp;gt; ${newfile}&lt;BR /&gt;&lt;BR /&gt;# end&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Feb 2006 06:48:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959662#M101012</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-02-14T06:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959663#M101013</link>
      <description>Another way as,&lt;BR /&gt;&lt;BR /&gt;oldfile=abc&lt;BR /&gt;newfile=$(sed -e '1!d' ${oldfile})&lt;BR /&gt;awk '(NR != 1) { print; }' ${oldfile} &amp;gt; ${newfile}&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu</description>
      <pubDate>Tue, 14 Feb 2006 06:57:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959663#M101013</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-02-14T06:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959664#M101014</link>
      <description>Just add the line of,&lt;BR /&gt;&lt;BR /&gt;rm -f ${oldfile} &lt;BR /&gt;&lt;BR /&gt;in above two solutions.&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu</description>
      <pubDate>Tue, 14 Feb 2006 06:59:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959664#M101014</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-02-14T06:59:03Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959665#M101015</link>
      <description>Hello, &lt;BR /&gt;&lt;BR /&gt;Basically, you need to get the first line "xyz". Use sed to do that. Then, move the file abc --&amp;gt; xyz. Delete the first line in xyz. &lt;BR /&gt;&lt;BR /&gt;-Arun &lt;BR /&gt;</description>
      <pubDate>Tue, 14 Feb 2006 07:09:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959665#M101015</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2006-02-14T07:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959666#M101016</link>
      <description>Hello yogesh, &lt;BR /&gt;&lt;BR /&gt;This should be useful, &lt;A href="http://www.student.northpark.edu/pemente/sed/sed1line.txt" target="_blank"&gt;http://www.student.northpark.edu/pemente/sed/sed1line.txt&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;-Arun</description>
      <pubDate>Tue, 14 Feb 2006 07:12:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959666#M101016</guid>
      <dc:creator>Arunvijai_4</dc:creator>
      <dc:date>2006-02-14T07:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959667#M101017</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Try this:&lt;BR /&gt;&lt;BR /&gt;perl -naF -e '$old=$ARGV;if ($.==1) {open(FH,"&amp;gt;",$F[0]);next};print FH' filename&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 14 Feb 2006 07:31:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959667#M101017</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-14T07:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959668#M101018</link>
      <description>This works fine for me.&lt;BR /&gt;&lt;BR /&gt;script scr1------------------starts&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;file=$1&lt;BR /&gt;var1=`cat $file | xargs | awk '{ print $1 }'`&lt;BR /&gt;sed "s/$var1//" $file | grep -v " " &amp;gt; file2&lt;BR /&gt;mv file2 $file&lt;BR /&gt;scprit scr1------------------ends&lt;BR /&gt;&lt;BR /&gt;# chmod +x scr1&lt;BR /&gt;# cat abc&lt;BR /&gt;xyz &lt;BR /&gt;123&lt;BR /&gt;12123&lt;BR /&gt;2q32&lt;BR /&gt;&lt;BR /&gt;Hope that helps.&lt;BR /&gt;Regards,&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;# ./scr1 abc&lt;BR /&gt;# cat abc&lt;BR /&gt;123&lt;BR /&gt;12123&lt;BR /&gt;2q321&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Feb 2006 07:33:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959668#M101018</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2006-02-14T07:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959669#M101019</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;...and if you want to remove the original file, use this version:&lt;BR /&gt;&lt;BR /&gt;perl -naF -e '$old=$ARGV;if ($.==1) {open(FH,"&amp;gt;",$F[0]);next};print FH;END{unlink $old}' filename&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 14 Feb 2006 07:34:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959669#M101019</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-02-14T07:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959670#M101020</link>
      <description>hurry ......&lt;BR /&gt;script should be like this:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;file=$1&lt;BR /&gt;var1=`cat $file | xargs | awk '{ print $1 }'`&lt;BR /&gt;sed "s/$var1//" $file | grep -v " " &amp;gt; file2&lt;BR /&gt;mv file2 $var1&lt;BR /&gt;&lt;BR /&gt;This will create the file with the name xyz.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Feb 2006 07:40:19 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959670#M101020</guid>
      <dc:creator>Bharat Katkar</dc:creator>
      <dc:date>2006-02-14T07:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959671#M101021</link>
      <description>I feel JRF is shown the best. :)&lt;BR /&gt;&lt;BR /&gt;#!/bin/sh&lt;BR /&gt;oldfile=abc&lt;BR /&gt;newfile=$(head -1 ${oldfile})&lt;BR /&gt;perl -ne 'print if ($. != 1)' ${oldfile} &amp;gt; ${newfile}&lt;BR /&gt;rm -f ${oldfile}&lt;BR /&gt;&lt;BR /&gt;# END&lt;BR /&gt;exit 0&lt;BR /&gt;&lt;BR /&gt;--&lt;BR /&gt;Muthu</description>
      <pubDate>Tue, 14 Feb 2006 08:09:30 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959671#M101021</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2006-02-14T08:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959672#M101022</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;Simple awk solution:&lt;BR /&gt;&lt;BR /&gt;awk 'END{system("rm -i " ARGV[1])} {if (NR==1) {f=$1} else {print &amp;gt;&amp;gt; f}}' x&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;- at end (ask to) delete the file &lt;BR /&gt;- if line 1 then pickup filenam in f&lt;BR /&gt;- any other line, print to file f&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Feb 2006 08:41:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959672#M101022</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-02-14T08:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: use of VI editor in script</title>
      <link>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959673#M101023</link>
      <description>Hi All, &lt;BR /&gt;Thanks for all help. I have used user solution and it resolved my problem. &lt;BR /&gt;Many thanks for your help.</description>
      <pubDate>Tue, 14 Feb 2006 09:16:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/use-of-vi-editor-in-script/m-p/4959673#M101023</guid>
      <dc:creator>yogesh_4</dc:creator>
      <dc:date>2006-02-14T09:16:10Z</dc:date>
    </item>
  </channel>
</rss>

