The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
regular expression jaber87 Shell Programming and Scripting 3 06-05-2008 03:07 AM
regular expression and awk nickg UNIX for Dummies Questions & Answers 2 08-16-2007 05:23 PM
regular expression...help!! andy2000 UNIX for Dummies Questions & Answers 6 07-18-2007 05:10 PM
help in regular expression Rakesh Ranjan High Level Programming 5 10-25-2006 01:00 PM
Regular Expression + Aritmetical Expression Z0mby Shell Programming and Scripting 2 05-21-2002 10:59 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-12-2004
tony3101's Avatar
tony3101 tony3101 is offline
Registered User
  
 

Join Date: Nov 2002
Location: The INTERNET
Posts: 27
Lightbulb Need a regular expression

H3llo

I need a regular expression to delete all my unused lines,
for example:

do not delete

do not delete

do not delete

do not delete

I tried something like the string below but it doesnt work

sed '/ .*$//g' file > file2

Tony
  #2 (permalink)  
Old 03-12-2004
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
To delete blank lines..

grep . file1

To delete blank lines and those lines which only contain spaces...

sed '/^ *$/d' file1

To delete blank lines and those lines which only contain spaces and tabs...

awk NF file1
  #3 (permalink)  
Old 03-12-2004
tony3101's Avatar
tony3101 tony3101 is offline
Registered User
  
 

Join Date: Nov 2002
Location: The INTERNET
Posts: 27
works great! thx u

( why is this site so slow?)
  #4 (permalink)  
Old 03-12-2004
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Quote:
Originally posted by tony3101

( why is this site so slow?)
Because you're running flash on a wimpy cpu. Click "user cp", "edit options" and pick something besides "green flash".

Or get a real cpu.
  #5 (permalink)  
Old 06-05-2008
abhisek.says abhisek.says is offline
Registered User
  
 

Join Date: May 2008
Posts: 9
Smile do deletee blank line including the tabs and spaces

sed '/^[ <tab>]*$/d' file ,
This works pretty nicely..
<tab> - you have to press tab key there..
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:52 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0