How do I change all of the "/" to ")" in all of lines of a file that end in ")"

Taylor

I am using vim and I think I know how to change all of the / to ) but I do not know how to apply it for only lines that end in )

I want to change this:

apples/oranges/grapes) 
apples/oranges/grapes 
apples/oranges/grapes)      
apples/oranges/grapes

to this:

apples)oranges)grapes)
apples/oranges/grapes
apples)oranges)grapes)
apples/oranges/grapes
G-Man Says 'Reinstate Monica'

The vim solution is very similar to the sed solution:

:g/)$/s!/!)!gEnter

I’m assuming that you want to edit only the lines where the last character is ).  If you want to include lines where ) is the last non-blank character, use

:g/)\s*$/s!/!)!gEnter
where \s is code for a space character (space or tab).  I'm using ! the way Hauke Laging uses +; that’s just a matter of personal preference.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I write all lines from less to a file?

How do I save some lines but not all?

How do I remove all the lines in a text file that are present in another text file in Windows?

How do I copy all the duplicate lines of a file to a new file in Python?

How do I change all lines to be black color in seaborn.lineplot?

How do I read a text file and print specified lines which match all conditions?

In a text file, how do I delete all lines subset of their immediately following line?

How do I delete all lines in a file starting from after a matching line?

How do I remove all lines in a file that are less than 6 characters?

How do I delete all lines in text file below certain text?

How do I loop through a file and remove all lines that fit the condition?

How do i delete all the lines in a file ending with colon using awk or sed?

How do I use grep to search for lines containing all words in a list with no specific order in a text file?

How do I make the "for" loop cycle through all lines of a text file in python 3.8?

How append a string at the end of all lines?

How can I remove all lines not containing `@` from a text file?

How can I delete all unordered lines from a text file?

How can i replace all lines in a file with a pattern using Powershell?

How can I extract certain portions of all lines in a text file?

How can I delete all lines in a file using vi?

How can I extract a portion of text from all lines of a file?

How do I save all generated Lines on the screen

how do i force Flutter to run all the lines inside the function?

How do I indent all of the lines after a line?

How do I display all the lines that contains the card number?

Python: How do I bus multiple lines of code in a function so that they can be turned off with a single # to change all to a comment?

How do I call screenmanager in python file part to change screens only when all spinners are selected

change json file from all lines to custom lines

How to copy first line of text file to start or end of all another lines?