Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Help for Unix text file processing

Re: Help for Unix text file processing

From: <Diana_Duncan_at_ttpartners.com>
Date: Wed, 06 Jun 2001 10:00:22 -0700
Message-ID: <F001.0031E60F.20010606084222@fatcity.com>

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: Diana_Duncan_at_ttpartners.com

                                                                                       
                                 
                    "Kumar,                                                            
                                 
                    Dharminder"               To:     Multiple recipients of list 
ORACLE-L <ORACLE-L_at_fatcity.com>       
                    <Dharminder.Kumar@        cc:                                      
                                 
                    bmonb.com>                Fax to:                                  
                                 
                    Sent by:                  Subject:     Help for Unix text file 
processing                           
                    root_at_fatcity.com                                                   
                                 
                                                                                       
                                 
                                                                                       
                                 
                    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: Dharminder.Kumar_at_bmonb.com

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: ListGuru_at_fatcity.com (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: Diana_Duncan_at_ttpartners.com

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: ListGuru_at_fatcity.com (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).
Received on Wed Jun 06 2001 - 12:00:22 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US