Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides

FAQ
It is currently Tue Jun 06, 2023 8:46 am


Tips & Tricks, Questions regarding shell scripts, awk, perl, sed and much more.

Author Message
debuser
  Post  Post subject: Remove empty lines in vi/vim  |  Posted: Mon Apr 26, 2010 11:06 am

Joined: Thu Aug 06, 2009 2:48 am
Posts: 105

Offline
 

Remove empty lines in vi/vim

Remove empty lines in files while editing them with vi or vim.
Code:
:%s/^[\ \t]*\n//g
or
Code:
:%s/^\n//g


Both worked for me. Make sure to test it for your environment.





Top
Display posts from previous:  Sort by  
E-mail friendPrint view

Topics related to - "Remove empty lines in vi/vim"
 Topics   Author   Replies   Views   Last post 
There are no new unread posts for this topic. Using sed to comment/uncomment lines in files

debuser

0

9148

Fri Apr 02, 2010 6:07 am

debuser View the latest post

There are no new unread posts for this topic. Unix shell - using TR to replace new lines with spaces

debuser

0

8832

Thu Feb 25, 2010 8:08 am

debuser View the latest post

There are no new unread posts for this topic. Linux / FreeBSD: Avoid bash history duplicate lines with HISTCONTROL

mandrei99

0

2561

Mon Jan 12, 2015 12:01 pm

mandrei99 View the latest post

There are no new unread posts for this topic. SED how to remove multiple white spaces from a string

debuser

0

11263

Thu Feb 25, 2010 7:14 am

debuser View the latest post

There are no new unread posts for this topic. Remove the character before the last character with SED - shell scripting

mandrei99

0

3891

Wed Nov 04, 2009 10:49 am

mandrei99 View the latest post

There are no new unread posts for this topic. Echo new line in linux - supress new line or echo multiple new lines

mandrei99

0

6020

Wed Jan 14, 2015 5:26 pm

mandrei99 View the latest post

There are no new unread posts for this topic. SED uncomment line - How to uncomment a line or all lines with SED

mandrei99

0

7766

Wed Jan 14, 2015 5:08 pm

mandrei99 View the latest post

 

Who is online
Users browsing this forum: No registered users and 0 guests
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum
Jump to:  
cronNews News Site map Site map SitemapIndex SitemapIndex RSS Feed RSS Feed Channel list Channel list


Delete all board cookies | The team | All times are UTC - 5 hours [ DST ]



phpBB SEO