The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Adding a word in front of a word of each line. Ramesh Vellanki Shell Programming and Scripting 4 07-02-2008 09:17 AM
find a word in a file, and change a word beneath it ?? vikas027 Shell Programming and Scripting 2 02-13-2008 04:23 PM
Removing a specific word from a created list erest8 UNIX for Dummies Questions & Answers 5 10-14-2007 05:11 AM
Can a shell script pull the first word (or nth word) off each line of a text file? tricky Shell Programming and Scripting 5 08-17-2006 06:29 AM
removing first bit from the word jazz High Level Programming 3 11-10-2005 04:52 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rating: Thread Rating: 1 votes, 1.00 average. Display Modes
  #1 (permalink)  
Old 06-15-2009
ravi.sadani19 ravi.sadani19 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 42
Vi - removing last word

Hi All,

I want to remove last word from a line using Vi.

Do we have any vi command for that.


line : ss dd ff gg
i have to run some vi command which can delete gg from the line


Thanks,
Ravi Sadani
  #2 (permalink)  
Old 06-15-2009
chatwizrd chatwizrd is offline
Banned
  
 

Join Date: Nov 2008
Posts: 67
ctrl + w when in insert mode
  #3 (permalink)  
Old 06-15-2009
ravi.sadani19 ravi.sadani19 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 42
Not working .. Getting nothing.
I have done esc I to be in insert mode then ctrl+w.
  #4 (permalink)  
Old 06-16-2009
panyam panyam is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2008
Posts: 474
Code:
http://azero.dk/support/editor/vi/
  #5 (permalink)  
Old 06-16-2009
ranjithpr ranjithpr is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 157
Below command in execute mode Remove last word from all lines

%s/ .[^ ]$//

Below command in execute mode Remove last word from line 5

5s/ .[^ ]$//

Below command in execute mode Remove last word from line 1 to 10

1,10s/ .[^ ]$//
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:54 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0