LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-08-2010, 01:29 PM   #1
Mr. Swillis
Member
 
Registered: Sep 2005
Location: The PNW
Distribution: Many. Slackware is the main reason I'm here though :)
Posts: 95

Rep: Reputation: 17
Help with find/replace in vi


Hello,

I'm in the middle of a data migration project and I have a text file where the data in one of the fields contains a "\" at the end of each line. I know how to do a find and replace on ALL backslashes using something like this:

Code:
:%s/\\//g
The above example would replace all backslashes with nothing, effectively "removing" them. Does anyone know how I can apply a similar function that only removes the backslashes that exist at the end of a line?

Thanks!

Swill
 
Old 02-08-2010, 01:33 PM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
add $ which means "at the end of the line"

edit: ^ means beginning of the line conversely. A command I use frequently when viewing config files for example is 'grep -v "^#" filename' which basically says show me the file minus any line that starts with a # sign.

Last edited by rweaver; 02-08-2010 at 01:34 PM.
 
Old 02-08-2010, 01:34 PM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

:%s/\\$//

Hope this helps.
 
Old 02-08-2010, 01:57 PM   #4
Mr. Swillis
Member
 
Registered: Sep 2005
Location: The PNW
Distribution: Many. Slackware is the main reason I'm here though :)
Posts: 95

Original Poster
Rep: Reputation: 17
Excellent, thanks for the quick replies. I figured the "$" would be involved, but I wasn't sure where to put it in the command. This totally did the trick for me.

Thanks again!

Swill
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can't find my find command! how to replace? dave247 Debian 4 11-19-2008 10:51 AM
Find and Replace dipuasks Linux - General 4 07-02-2008 01:52 PM
Find and Replace upwordz Linux - Newbie 7 05-10-2007 09:03 PM
find and replace happy78 Programming 11 09-10-2005 10:21 AM
Find and Replace? duerra Linux - General 9 01-28-2004 04:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration