<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Tech-Recipes - Latest Comments in Remove blank lines from a file using grep</title><link>http://tech-recipes.disqus.com/</link><description>Cookbook of Tech Tutorials</description><atom:link href="https://tech-recipes.disqus.com/remove_blank_lines_from_a_file_using_grep_unix_tech_recipes/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 08 Aug 2011 09:48:35 -0000</lastBuildDate><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-280409032</link><description>&lt;p&gt;RDLC is worst tool&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Latthe</dc:creator><pubDate>Mon, 08 Aug 2011 09:48:35 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-280406517</link><description>&lt;p&gt;My Name is Latthe&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Latthe</dc:creator><pubDate>Mon, 08 Aug 2011 09:44:20 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-193227094</link><description>&lt;p&gt;thank you&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">2100822</dc:creator><pubDate>Thu, 28 Apr 2011 05:34:22 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-173585455</link><description>&lt;p&gt;the problem with grep is it has a line limit (2048) lines.  If you file has more lines than that it will stop when it gets there.  I just learned a cool way to do the same thing using awk. I don't think it has the same limitations.&lt;/p&gt;&lt;p&gt;awk '{ if (length($0) &amp;gt; 0){ print $0 }}' inputfilename &amp;gt;&amp;gt; outputfilename&lt;/p&gt;&lt;p&gt;This will search inputfilename and as long as the line has one character on it it will be sent to the outputfilename eliminating blank lines in outputfilename.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Guest</dc:creator><pubDate>Mon, 28 Mar 2011 18:36:13 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-170715766</link><description>&lt;p&gt;without the -c flag it worked for me.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">r00fus</dc:creator><pubDate>Thu, 24 Mar 2011 00:04:42 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-154129075</link><description>&lt;p&gt;this is the the only one that worked for me on a file created on Windows, thanks bryansenter&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">colacao</dc:creator><pubDate>Tue, 22 Feb 2011 13:36:13 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-85714734</link><description>&lt;p&gt;Thank you&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Tntnt</dc:creator><pubDate>Sun, 10 Oct 2010 14:45:28 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-58451357</link><description>&lt;p&gt;add&lt;br&gt;| grep -v "^$"&lt;br&gt;to the end of the command chain to eliminate blank lines.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mark</dc:creator><pubDate>Thu, 24 Jun 2010 11:12:28 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-50064118</link><description>&lt;p&gt;both are corrects with sed and with grep but i have same question as anonymous &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">sonu</dc:creator><pubDate>Thu, 13 May 2010 04:28:42 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-40284878</link><description>&lt;p&gt;It's cool~~~~  thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">peterpan</dc:creator><pubDate>Thu, 18 Mar 2010 03:07:03 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-23567099</link><description>&lt;p&gt;thanks&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">sg1973</dc:creator><pubDate>Thu, 19 Nov 2009 16:35:04 -0000</pubDate></item><item><title>Re: Remove blank lines from a file using grep</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-15066037</link><description>&lt;p&gt;Include blank lines that aren't really blank (tabs, spaces, CRLF, etc)&lt;/p&gt;&lt;p&gt;grep -vc '^[[:space:]]*$'&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</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</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-14454969</link><description>&lt;p&gt;Have you tried the above commans...?&lt;/p&gt;</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</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-7182352</link><description>&lt;p&gt;awsome&lt;/p&gt;</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</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-4958179</link><description>&lt;p&gt;All ways together, :-)&lt;/p&gt;&lt;p&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;/p&gt;&lt;p&gt;&lt;a href="http://unstableme.blogspot.com" rel="nofollow noopener" target="_blank" title="unstableme.blogspot.com"&gt;unstableme.blogspot.com&lt;/a&gt;&lt;/p&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</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766836</link><description>&lt;p&gt;The easiest way to remove blank lines from a file is to use a sed statement. The following syntax removes the blank lines.&lt;/p&gt;&lt;p&gt;# cat my_file | sed /^$/d&lt;/p&gt;</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</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766835</link><description>&lt;p&gt;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 noopener" target="_blank" title="http://entrian.com/"&gt;entrian.com&lt;/a&gt;&lt;/p&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</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766834</link><description>&lt;p&gt;.. or, quicker, grep . &amp;lt;filename&amp;gt;&lt;/p&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</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766833</link><description>&lt;p&gt;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;/p&gt;&lt;p&gt;Raxxal&lt;/p&gt;</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</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766832</link><description>&lt;p&gt;Great catch!  You are absolutely correct.  The recipe has been repaired.  Thank you for helping to improve Tech-Recipes.&lt;/p&gt;&lt;p&gt;Quinn&lt;/p&gt;</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</title><link>http://www.tech-recipes.com/rx/67/remove-blank-lines-from-a-file-using-grep/#comment-2766831</link><description>&lt;p&gt;From man grep:&lt;/p&gt;&lt;p&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"&lt;/p&gt;</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>