Here are some sed commands that do what you want -- in the [] brackets,
there is a space and a tab.

$ cat removeblanks.sed
/^[     ]*$/d
s/^[    ]*//
s/[     ]*$//

Here's a test file.
$ cat test.txt



This is a real line, the lines above are a carriage return, a tab and
spaces.
                This line starts and ends with tabs.
  This line starts and ends with spaces
        This line starts and ends with spaces and tabs

Here's what you run:
$ sed -f removeblanks.sed test.txt
This is a real line, the lines above are a carriage return, a tab and
spaces.
This line starts and ends with tabs.
This line starts and ends with spaces
This line starts and ends with spaces and tabs


HTH!

Diana Duncan
TITAN Technology Partners
One Copley Parkway, Ste 540
Morrisville, NC  27560
VM: 919.466.7337 x 316
F: 919.466.7427
E: [EMAIL PROTECTED]


                                                                                       
                                 
                    "Kumar,                                                            
                                 
                    Dharminder"               To:     Multiple recipients of list 
ORACLE-L <[EMAIL PROTECTED]>       
                    <Dharminder.Kumar@        cc:                                      
                                 
                    bmonb.com>                Fax to:                                  
                                 
                    Sent by:                  Subject:     Help for Unix text file 
processing                           
                    [EMAIL PROTECTED]                                                   
                                 
                                                                                       
                                 
                                                                                       
                                 
                    06/06/2001 10:55                                                   
                                 
                    AM                                                                 
                                 
                    Please respond to                                                  
                                 
                    ORACLE-L                                                           
                                 
                                                                                       
                                 
                                                                                       
                                 




> Hey all,
>
> I am looking for some commands like ( grep, egrep, sed etc) to do the
> following on a Unix box.
>
> 1. Command to take out all the blank line from a text file. The blank
line
> may include tabs and whitespaces.
> 2. Command to take out the trailing and starting blanks and tabs from the
> each line of the text file.
> 3. Command for the above two tasks combined.
>
> Thanks in advance.
>
> Dharminder Kumar
>
>
>
>
This e-mail and any attachments may contain confidential and privileged
information. If you are not the intended recipient, please notify the
sender
immediately by return e-mail, delete this e-mail and destroy any copies.
Any
dissemination or use of this information by a person other than the
intended
recipient is unauthorized and may be illegal. Unless otherwise stated,
opinions expressed in this e-mail are those of the author and are not
endorsed by the author's employer.


--
Please see the official ORACLE-L FAQ: http://www.orafaq.com
--
Author: Kumar, Dharminder
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).




-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: [EMAIL PROTECTED]

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

Reply via email to