Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



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

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-09-2010
Registered User
 

Join Date: Mar 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
vi command

What is the command in 'vi' that I can replace the right most '/' with a space?
In a file, the directory level is various and I need a space between the directory path and file name:

i.e (before)
dir1/dir2/dir3/dir4/file
dir1/dir2/dir3/dir4/dir5/file
dir1/dir2/dir3/dir4/dir5/dir5/file

I want it to be (after)
dir1/dir2/dir3/dir4 file
dir1/dir2/dir3/dir4/dir5 file
dir1/dir2/dir3/dir4/dir5/dir6 file

comments and helps are appreciated.
Sponsored Links
    #2  
Old 03-09-2010
anbu23's Avatar
anbu23 anbu23 is offline Forum Advisor  
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,849
Thanks: 3
Thanked 44 Times in 43 Posts

Code:
%s,/\([^\/]*\)$, \1,

Sponsored Links
    #3  
Old 03-09-2010
Registered User
 

Join Date: Mar 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for reply.

ignore my previous comment. The command works

Last edited by ywu081006; 03-09-2010 at 05:24 PM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
can anyone help with shell script command about searching word with grep command? aintour Shell Programming and Scripting 2 10-14-2009 04:51 PM
problem with output of find command being input to basename command... new_learner UNIX for Dummies Questions & Answers 2 12-14-2008 01:56 AM
awk/sed Command : Parse parameter file / send the lines to the ksh export command rajan_san Shell Programming and Scripting 4 11-06-2008 12:29 PM
assign a command line argument and a unix command to awk variables sweta_doshi Shell Programming and Scripting 0 08-08-2008 06:54 AM
Help Required: Command to find IP address and command executed of a user loggedout Security 2 08-06-2008 08:12 PM



All times are GMT -4. The time now is 12:54 AM.