Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Doesn't remove ALL the blank lines....

Status
Not open for further replies.

RVSachin

Technical User
Nov 12, 2001
77
IN
Hi,

I am trying to remove blank lines from a report by doing
grep -v "^$" file1 > file2
such that file2 doesn't contain blank lines.

Although it works on most of the blank lines, I still see few blank lines such as the one in the code. I am wondering why it doesn't remove *ALL* blank lines in the file.

Also, it will be helpful if any of you can guide me to how to remove all blank lines, and remove tab-spaces in each line if there's any. Getting it to work on the following peice of code using Korn-shell commands will be very helpful.

Thanks,


Code:
Intro to Korn shell programming
*******************************


Why scripting?
Scripting, when done right, is a fast, easy way to "get the job done", without the usual "code,compile,test,debug" overhead of writing in C or some other compiled language. It is easier than C for multiple reasons: 

	1.	Scripting commands tend to be more readable
	2.	Scriping languages tend to come with powerful tools
	3.	There is no "compile" phase

UNIX tends to take #2 to extremes, since it comes standard with "powerful tools" that can be strung together with pipes or other mechanisms, to get the result you want, with a short development time.
 
Have you tried this ?
grep -v '^[ <Tab>]*$' file1 > file2
Replacing <Tab> by a tab character

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
RVSachin: they are simply NOT blanc
as phv said, a line with blancs is NOT a blanc line.

Ygor: elegant :)

my preferred ( == phv's grep )

sed '/^[SpaceTab]*$/d' in >out
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top