Re: need to trim spaces from sqlplus output

From: Andrew Kerber <andrew.kerber_at_gmail.com>
Date: Tue, 18 Jan 2011 15:42:53 -0600
Message-ID: <AANLkTikdRTb21jcPZDvTzpgbVHM6TSxOArpUsvz3pZN=_at_mail.gmail.com>



um tried that. Couldn't find info applicable to the situation. The Oracle trim command doesnt work in that situation. However, the sed command does what is needed.

While a true sed guru can probably do this without the interim pipe, this does what I needed. I was using the | as the delimiter in the file also:

sed 's# *|#|#g' infile.csv | sed 's/|[ ]*/|/g' > output.txt

On Tue, Jan 18, 2011 at 3:17 PM, David Barbour <david.barbour1_at_gmail.com>wrote:

> Uh............ try Google? (Hint: look for "Oracle" + "trim")
>
>
> On Tue, Jan 18, 2011 at 2:45 PM, Andrew Kerber <andrew.kerber_at_gmail.com>wrote:
>
>> Yeah, its a matter of time. If I can just fix the output files with some
>> simple commands its easy. To do it the other way, I have to go and modify
>> 32 separate queries.
>>
>>
>> On Tue, Jan 18, 2011 at 1:40 PM, Michael Moore <michaeljmoore_at_gmail.com>wrote:
>>
>>> select last name||'|'||first_name from ... etc
>>>
>>> In other words, avoid the problem in the first place. This might not be
>>> an option for you.
>>>
>>> Mike
>>>
>>> On Tue, Jan 18, 2011 at 9:02 AM, Radoulov, Dimitre <
>>> cichomitiko_at_gmail.com> wrote:
>>>
>>>> On 18/01/2011 17:50, Andrew Kerber wrote:
>>>>
>>>>> Does anyone have a unix script to trim spaces prior to the column
>>>>> separators in sqlplus output, ie, I have output like his:
>>>>>
>>>>> LAST NAME |FIRST NAME |BIRTHDAY
>>>>> Kerber |Andrew |Aug01
>>>>>
>>>>> That I want to look like this:
>>>>>
>>>>> LAST NAME|FIRST NAME|BIRTHDAY
>>>>> Kerber|Andrew|Aug01
>>>>>
>>>>
>>>>
>>>> sed 's# *|#|#g' infile
>>>>
>>>>
>>>>
>>>> Regards
>>>> Dimitre
>>>>
>>>> --
>>>> http://www.freelists.org/webpage/oracle-l
>>>>
>>>>
>>>>
>>>
>>
>>
>> --
>> Andrew W. Kerber
>>
>> 'If at first you dont succeed, dont take up skydiving.'
>>
>
>

-- 
Andrew W. Kerber

'If at first you dont succeed, dont take up skydiving.'

--
http://www.freelists.org/webpage/oracle-l
Received on Tue Jan 18 2011 - 15:42:53 CST

Original text of this message