<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"><channel><title>Tech-Recipes - Latest Comments in Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://tech-recipes.disqus.com/</link><description>Cookbook of Tech Tutorials</description><language>en</language><lastBuildDate>Wed, 19 Aug 2009 11:44:37 -0000</lastBuildDate><item><title>Re: Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-15066037</link><description>Include blank lines that aren't really blank (tabs, spaces, CRLF, etc)&lt;br&gt;&lt;br&gt;grep -vc '^[[:space:]]*$'</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">bryansenter</dc:creator><pubDate>Wed, 19 Aug 2009 11:44:37 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-14454969</link><description>Have you tried the above commans...?</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">sivapitchai</dc:creator><pubDate>Fri, 07 Aug 2009 18:22:49 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-7182352</link><description>awsome</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Luis </dc:creator><pubDate>Fri, 13 Mar 2009 16:46:04 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-4958179</link><description>All ways together, :-)&lt;br&gt;&lt;br&gt;$ grep -v '^$' file&lt;br&gt;$ grep '.' file&lt;br&gt;$ sed '/^$/d' file&lt;br&gt;$ sed -n '/^$/!p' file&lt;br&gt;$ awk NF file&lt;br&gt;$ awk '/./' file&lt;br&gt;&lt;br&gt;&lt;a href="http://unstableme.blogspot.com" rel="nofollow"&gt;unstableme.blogspot.com&lt;/a&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Jadu Saikia</dc:creator><pubDate>Wed, 07 Jan 2009 06:01:31 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766836</link><description>The easiest way to remove blank lines from a file is to use a sed statement. The following syntax removes the blank lines.&lt;br&gt;&lt;br&gt;# cat my_file | sed /^$/d</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Sun, 22 Jun 2008 23:55:49 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766835</link><description>This wasn't working for me using Cygwin, then I realised that the file I was looking at had Windows line endings.  There are any number of solutions to this, but the one I chose was to pipe through tr -d "r" before piping through grep.  Then it worked like a charm.  -- Richie Hindle, richie@&lt;a href="http://entrian.com/" rel="nofollow"&gt;entrian.com&lt;/a&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Tue, 22 Jan 2008 22:17:56 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766834</link><description>.. or, quicker, grep . &amp;lt;filename&amp;gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Fri, 03 Sep 2004 00:08:08 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766833</link><description>By the way, if you want to see the $ sign, in vi  enter  :set list&lt;br&gt;also, in cat do the following: cat -vet&lt;br&gt;&lt;br&gt;Raxxal</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">raxxal</dc:creator><pubDate>Thu, 13 May 2004 08:02:13 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766832</link><description>Great catch!  You are absolutely correct.  The recipe has been repaired.  Thank you for helping to improve Tech-Recipes.&lt;br&gt;&lt;br&gt;Quinn</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">qmchenry</dc:creator><pubDate>Tue, 25 Nov 2003 01:31:59 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep | UNIX | Tech-Recipes</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766831</link><description>From man grep:&lt;br&gt;&lt;br&gt;&amp;lt;ul id="quote"&amp;gt;The  caret ^ and the dollar sign $ are metacharacters that respectively&lt;br&gt;       match the empty string at the beginning and end of a line.&amp;lt;/ul&amp;gt;&lt;br&gt;Not  "$=beginning of line, ^=end of line"</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Anonymous</dc:creator><pubDate>Mon, 24 Nov 2003 22:33:49 -0000</pubDate></item></channel></rss>