LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-06-2016, 01:57 PM   #1
sdscadc
LQ Newbie
 
Registered: Oct 2016
Posts: 2

Rep: Reputation: Disabled
deleting all spaces at end of line in vi


How can I delete, all (blank) spaces at end of each line in vi editor.
 
Old 10-06-2016, 02:12 PM   #2
ccj4467
Member
 
Registered: Jan 2009
Posts: 34

Rep: Reputation: 5
Not sure in vi but this is a little sed statement that does it:

Code:
sed 's/ *$//' oldfile > newfile
 
Old 10-06-2016, 02:26 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,005

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
Same in vi
 
1 members found this post helpful.
Old 10-07-2016, 02:23 AM   #4
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,780

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
In vi it is a : command
Code:
:%s/ *$//
where the line address % is short for 1,$ (from 1st line to last line).
 
2 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Deleting a line that matches a string and also the line above it LinuxChiq Linux - Newbie 2 06-23-2012 05:29 PM
shell question: pad end of each line with spaces to = 80 chars ?? di11rod Programming 19 04-21-2011 07:03 PM
deleting duplicate lines without deleting first instance of the duplicated line jkeertir Linux - Newbie 2 02-07-2011 06:55 AM
Deleting empty line at end of text file in BASH human2.0 Linux - General 8 04-01-2009 02:44 AM
deleting all spaces at end of line in vi Tonatiuh Linux - General 4 08-16-2006 02:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:46 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