<?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: vi command ? in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662003#M20384</link>
    <description>Does the Esc-k imply you are using ksh?&lt;BR /&gt;&lt;BR /&gt;Under bash, the following command will do the substitution you seek:&lt;BR /&gt;$(echo !mkdir | sed -e "s/foo/toe/g")&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;# mkdir foo1 foo2 foo3&lt;BR /&gt;# ls&lt;BR /&gt;foo1  foo2  foo3&lt;BR /&gt;# $(echo !mkdir | sed -e "s/foo/toe/g")&lt;BR /&gt;$(echo mkdir foo1 foo2 foo3 | sed -e "s/foo/toe/g")&lt;BR /&gt;# ls&lt;BR /&gt;foo1  foo2  foo3  toe1  toe2  toe3&lt;BR /&gt;&lt;BR /&gt;I'm not sure how to suppress the echo of that command line to the screen though (if it even matters) redirecting to &amp;gt;/dev/null didn't seem to work.&lt;BR /&gt;&lt;BR /&gt;-Jared</description>
    <pubDate>Tue, 01 Nov 2005 22:24:23 GMT</pubDate>
    <dc:creator>Jared Middleton</dc:creator>
    <dc:date>2005-11-01T22:24:23Z</dc:date>
    <item>
      <title>vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661994#M20375</link>
      <description>Hello All,&lt;BR /&gt;&lt;BR /&gt;  Just wanted to ask (2) questions about using vi :&lt;BR /&gt;&lt;BR /&gt;1) how do you delete text from current line to end of file ?&lt;BR /&gt;&lt;BR /&gt;2) from command line, how do you change/substitute a string throughout the entire line :&lt;BR /&gt;ex:&lt;BR /&gt;command # 1 &lt;BR /&gt;# mkdir foo1 foo2 foo3 foo4&lt;BR /&gt;&lt;BR /&gt;I want pull this same command from history&lt;BR /&gt;( esc k ) and substitute "foo" with "toe"&lt;BR /&gt;so it executes :&lt;BR /&gt;&lt;BR /&gt;# mkdir toe1 toe2 toe3 toe4&lt;BR /&gt;&lt;BR /&gt;please advise, Thanks&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Nov 2005 11:21:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661994#M20375</guid>
      <dc:creator>Jerry_109</dc:creator>
      <dc:date>2005-11-01T11:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661995#M20376</link>
      <description>The answer for (1) is 'dG'&lt;BR /&gt;&lt;BR /&gt;taken from the 'dd' to delete a line and the 'G' to go to end of file.&lt;BR /&gt;&lt;BR /&gt;For (2) I would use sed. &lt;BR /&gt;Attached file gives lots of 1 liners for sed. This is from an old post which came from an old site.</description>
      <pubDate>Tue, 01 Nov 2005 11:41:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661995#M20376</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2005-11-01T11:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661996#M20377</link>
      <description>First command works fine, thanks, but the second does not seem clear? I'm I using "sed"&lt;BR /&gt;from the command line? Is there an example to use after the "esc k" ?</description>
      <pubDate>Tue, 01 Nov 2005 12:39:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661996#M20377</guid>
      <dc:creator>Jerry_109</dc:creator>
      <dc:date>2005-11-01T12:39:53Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661997#M20378</link>
      <description>for example in "vi" I use :&lt;BR /&gt;1,$s/foo/toe/g&lt;BR /&gt;&lt;BR /&gt;How do I use this from the command line ?</description>
      <pubDate>Tue, 01 Nov 2005 12:43:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661997#M20378</guid>
      <dc:creator>Jerry_109</dc:creator>
      <dc:date>2005-11-01T12:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661998#M20379</link>
      <description>cat $file | sed s/foo/toe/g&lt;BR /&gt;&lt;BR /&gt;Run this command and you will see output on screen. Can redirect this output to a file&lt;BR /&gt;&lt;BR /&gt;cat $file | sed s/foo/toe/g &amp;gt; $file.2&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Nov 2005 13:29:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661998#M20379</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2005-11-01T13:29:20Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661999#M20380</link>
      <description>Sorry I was not clear on what I was trying to do. I was trying to change a particular string from the command line to execute using&lt;BR /&gt;the history to pull up previous cmd, and substitute to "string1" w/ "string2" on the command line. I still might not be clear, but as an example :&lt;BR /&gt;&lt;BR /&gt;command1&lt;BR /&gt;# mkdir foo1 foo2 foo3 foo3&lt;BR /&gt;# "esc k"  returns&lt;BR /&gt;# mkdir foo1 foo2 foo3 foo3&lt;BR /&gt;&lt;BR /&gt;When the history returns the previous command&lt;BR /&gt;above, that's where I want to substitute&lt;BR /&gt;"foo" w/ "toe" ? I'm trying to substitute directly from cmd line, and not output to a file.</description>
      <pubDate>Tue, 01 Nov 2005 13:42:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3661999#M20380</guid>
      <dc:creator>Jerry_109</dc:creator>
      <dc:date>2005-11-01T13:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662000#M20381</link>
      <description>Putting it that way, I'm not sure this can be done. &lt;BR /&gt;&lt;BR /&gt;If you have the 'esc-k' functionality, the editing functionality is probably with vi (this is a guess). So bring the history, mkdir toe1 toe2 toe3 toe4, the cursor will be on the 'm' of the mkdir. Use the 'w' key to advance 1 word, 'cw' to change word from foo to toe, hit the esc key to go back into command mode, 'w' to advance to next word, 'cw' to change word from foo1 to toe1, etc...&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 01 Nov 2005 13:50:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662000#M20381</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2005-11-01T13:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662001#M20382</link>
      <description>Here is a vi cheat sheet I have lying around.&lt;BR /&gt;&lt;BR /&gt;LAST LINE MODE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;/PATTERN                search forward &lt;BR /&gt;?PATTERN                search backwards&lt;BR /&gt;/ or ? or n             repeat last search&lt;BR /&gt;N                       reverse last search&lt;BR /&gt;:w                      write buffer to disk&lt;BR /&gt;:w NEWFILE              write buffer to NEWFILE&lt;BR /&gt;:w &amp;gt;&amp;gt; FILE              append buffer to FILE&lt;BR /&gt;:w! FILE                force a write to FILE&lt;BR /&gt;:wq                     write then quit&lt;BR /&gt;:q                      quit&lt;BR /&gt;:q!                     quit without writing&lt;BR /&gt;:f                      show file name and line #&lt;BR /&gt;:cd DIRECTORY           change DIRECTORY&lt;BR /&gt;:r                      read file into buffer&lt;BR /&gt;:r FILE                 read named FILE&lt;BR /&gt;:e                      edit&lt;BR /&gt;:e!                     discard buffer and edit&lt;BR /&gt;:e FILE                 edit a FILE&lt;BR /&gt;:e #                    pop between files&lt;BR /&gt;:s/OLD/NEW/             current line sub. 1st&lt;BR /&gt;:s/OLD/NEW/g            current line sub. all&lt;BR /&gt;:1,7s/OLD/NEW           lines 1-7 sub. all&lt;BR /&gt;:%s/OLD/NEW             all lines sub. 1st&lt;BR /&gt;:%s/OLD/NEW/g           all lines sub. all&lt;BR /&gt;:%s/^/PATTERN /g        insert PATTERN at beginning of line all lines&lt;BR /&gt;:%s/$/ PATTERN/g        insert PATTERN at end of all lines&lt;BR /&gt;:set nu                 show line numbers&lt;BR /&gt;:set nonu               hide line numbers&lt;BR /&gt;:set sm                 enable matching ()s&lt;BR /&gt;:set nosm               disable matching ()s&lt;BR /&gt;&lt;BR /&gt;$                       end of line&lt;BR /&gt;^                       beginning of line&lt;BR /&gt;/                       search&lt;BR /&gt;:%s/.$//                remove last character on every line&lt;BR /&gt;&lt;BR /&gt;INSERT MODE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;a                       append after cursor&lt;BR /&gt;A                       append at end of line&lt;BR /&gt;i                       insert before cursor&lt;BR /&gt;I                       insert at start of line&lt;BR /&gt;o                       open a line below cursor&lt;BR /&gt;O                       open a line above cursor&lt;BR /&gt;cw                      change word at cursor&lt;BR /&gt;c#w                     change # of words&lt;BR /&gt;C                       change text to end of line&lt;BR /&gt;r                       replace a character&lt;BR /&gt;R                       replace text unti &lt;ESC&gt;&lt;BR /&gt;#a&lt;ESC&gt;                 add # copies of text&lt;BR /&gt;#a&lt;ESC&gt;                 add # copies of text at line end&lt;BR /&gt;#i&lt;ESC&gt;                 insert # copies of text&lt;BR /&gt;#I&lt;ESC&gt;                 insert # copies of text at line start&lt;BR /&gt;^w                      erase last word&lt;BR /&gt;&lt;ESC&gt;                   go to command mode&lt;BR /&gt;&lt;BR /&gt;COMMAND MODE&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;h                       move cursor left&lt;BR /&gt;l                       move cursor right&lt;BR /&gt;j                       move cursor down one line&lt;BR /&gt;k                       move cursor up one line&lt;BR /&gt;G                       go to end of file&lt;BR /&gt;#G                      go to line #&lt;BR /&gt;H                       go to top of screen&lt;BR /&gt;M                       go to middle of screen&lt;BR /&gt;L                       go to bottom of screen&lt;BR /&gt;w                       move cursor forward one word&lt;BR /&gt;b                       move cursor back one word&lt;BR /&gt;#w                      move cursor forward # words&lt;BR /&gt;#b                      move cursor back # words&lt;BR /&gt;&lt;CTRL&gt;F                 scroll forward one page&lt;BR /&gt;&lt;CTRL&gt;B                 scroll back one page&lt;BR /&gt;x                       delete character&lt;BR /&gt;dd                      delete line&lt;BR /&gt;#dd                     delete # lines&lt;BR /&gt;dw                      delete word&lt;BR /&gt;#dw                     delete # words&lt;BR /&gt;d$                      delete to end of line&lt;BR /&gt;P                       paste before cursor&lt;BR /&gt;p                       paste after cursor&lt;BR /&gt;"vp                     paste buffer v after cursor&lt;BR /&gt;xp                      transpose two characters&lt;BR /&gt;Y                       yank a line&lt;BR /&gt;#Y                      yank # lines&lt;BR /&gt;"v#Y                    yank # lines to buffer v&lt;BR /&gt;.                       repeat last command&lt;BR /&gt;&lt;CTRL&gt;G                 show which line on&lt;BR /&gt;u                       undo&lt;BR /&gt;&lt;BR /&gt;CHANGE A VALUE THROUGHT A FILE&lt;BR /&gt;:g/$oldpattern/s//$newpattern/g&lt;BR /&gt;&lt;BR /&gt;this was for changing DNS values in the db.* files&lt;BR /&gt;&lt;BR /&gt;:g/SOA/s/$oldpattern/$newpattern/g&lt;BR /&gt;&lt;BR /&gt;The 'g' at the beginning and end of the command indicate that the changes are to occur horizontally and vertically&lt;/CTRL&gt;&lt;/CTRL&gt;&lt;/CTRL&gt;&lt;/ESC&gt;&lt;/ESC&gt;&lt;/ESC&gt;&lt;/ESC&gt;&lt;/ESC&gt;&lt;/ESC&gt;</description>
      <pubDate>Tue, 01 Nov 2005 13:53:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662001#M20382</guid>
      <dc:creator>Rick Garland</dc:creator>
      <dc:date>2005-11-01T13:53:10Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662002#M20383</link>
      <description>Thanks for all the support. I saw another admin do this some time ago, and let him get away without getting the command. I'll keep&lt;BR /&gt;trying.</description>
      <pubDate>Tue, 01 Nov 2005 13:55:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662002#M20383</guid>
      <dc:creator>Jerry_109</dc:creator>
      <dc:date>2005-11-01T13:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662003#M20384</link>
      <description>Does the Esc-k imply you are using ksh?&lt;BR /&gt;&lt;BR /&gt;Under bash, the following command will do the substitution you seek:&lt;BR /&gt;$(echo !mkdir | sed -e "s/foo/toe/g")&lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;# mkdir foo1 foo2 foo3&lt;BR /&gt;# ls&lt;BR /&gt;foo1  foo2  foo3&lt;BR /&gt;# $(echo !mkdir | sed -e "s/foo/toe/g")&lt;BR /&gt;$(echo mkdir foo1 foo2 foo3 | sed -e "s/foo/toe/g")&lt;BR /&gt;# ls&lt;BR /&gt;foo1  foo2  foo3  toe1  toe2  toe3&lt;BR /&gt;&lt;BR /&gt;I'm not sure how to suppress the echo of that command line to the screen though (if it even matters) redirecting to &amp;gt;/dev/null didn't seem to work.&lt;BR /&gt;&lt;BR /&gt;-Jared</description>
      <pubDate>Tue, 01 Nov 2005 22:24:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662003#M20384</guid>
      <dc:creator>Jared Middleton</dc:creator>
      <dc:date>2005-11-01T22:24:23Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662004#M20385</link>
      <description>Yes, ksh</description>
      <pubDate>Wed, 02 Nov 2005 09:55:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662004#M20385</guid>
      <dc:creator>Jerry_109</dc:creator>
      <dc:date>2005-11-02T09:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662005#M20386</link>
      <description>When you do the &lt;ESC&gt; k and pull up a previous command, type a "v", and it will load that command into vi proper.&lt;BR /&gt;&lt;BR /&gt;(This assumes you have "set -o vi" set, which it sound like you do.)&lt;BR /&gt;&lt;BR /&gt;You can then use your typical editing commands to modify the shell command or script - this is VERY handy for developing small shell scripts, by the way.&lt;BR /&gt;&lt;BR /&gt;so:&lt;BR /&gt;&lt;BR /&gt;# mkdir foo1 foo2 foo3 foo4&lt;BR /&gt;( esc k )&lt;BR /&gt;v&lt;BR /&gt;:s/foo/toe/g&lt;BR /&gt;ZZ   --- to write, quit, execute command&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Vince&lt;BR /&gt;&lt;/ESC&gt;</description>
      <pubDate>Fri, 04 Nov 2005 16:25:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662005#M20386</guid>
      <dc:creator>Vincent Fleming</dc:creator>
      <dc:date>2005-11-04T16:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: vi command ?</title>
      <link>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662006#M20387</link>
      <description>You are the man, it works great.&lt;BR /&gt;&lt;BR /&gt;Thanks.......... :&amp;gt;) !</description>
      <pubDate>Fri, 04 Nov 2005 16:32:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/vi-command/m-p/3662006#M20387</guid>
      <dc:creator>Jerry_109</dc:creator>
      <dc:date>2005-11-04T16:32:26Z</dc:date>
    </item>
  </channel>
</rss>

