From: dsids on
On Oct 3, 4:35 pm, pk <p...(a)pk.invalid> wrote:
> Lew Pitcher wrote:
> > On October 3, 2009 08:15, in comp.unix.shell, Danish
> > (me.linuxad...(a)gmail.com) wrote:
>
> >> Hi,
>
> >> Please tell me how to remove the non printing characters from a test
> >> file.
>
> > cat test_file | tr -cd '[:print:]'
>
> Careful with that one...it will remove newlines! Maybe this:
>
> tr -cd '[:print:]\n' < test_file

Thanks all of you. i got the output from the one pk provided. I gotta
try the other ones too.
From: Marcel Bruinsma on
Am Samstag, 3. Oktober 2009 15:35, Lew Pitcher a écrit :

> On October 3, 2009 08:15, in comp.unix.shell, Danish
> (me.linuxadmin(a)gmail.com) wrote:
^^^^^

>> Please tell me how to remove the non printing characters
>> from a test file.
>
> cat test_file | tr -cd '[:print:]'

Because of the 'linuxadmin' in the OP's address, it
might be useful to know that GNU (GNU is *not* UNIX)
tr does not conform to IEEE Std 1003.1, and that the
character class notation will not necessarily do what
is expected.

Obviously, under UNIX it will work as expected.

--
printf -v email $(echo \ 155 141 162 143 145 154 142 162 165 151 \
156 163 155 141 100 171 141 150 157 157 056 143 157 155|tr \ \\\\)
# Live every life as if it were your last! #
From: pk on
Kenny McCormack wrote:

> In article <3784501.N2KK5ppBuW(a)xkzjympik>, pk <pk(a)pk.invalid> wrote:
>>Lew Pitcher wrote:
>>
>>> On October 3, 2009 08:15, in comp.unix.shell, Danish
>>> (me.linuxadmin(a)gmail.com) wrote:
>>>
>>>> Hi,
>>>>
>>>>
>>>> Please tell me how to remove the non printing characters from a test
>>>> file.
>>>
>>> cat test_file | tr -cd '[:print:]'
>>
>>Careful with that one...it will remove newlines! Maybe this:
>>
>>tr -cd '[:print:]\n' < test_file
>
> The OP said he wanted to remove non-printing characters...

Yes true. My suspicion came from the fact that he was trying to use dos2unix
to do that, which could suggest the file is mostly a text file with some
spurious non-printing characters (other than \n). But you're right, whether
\n (and perhaps \t and a few others) should be included among
the "non-printing" characters only the OP can tell.
From: dsids on
On Oct 3, 4:44 pm, pk <p...(a)pk.invalid> wrote:
> Kenny McCormack wrote:
> > In article <3784501.N2KK5ppBuW(a)xkzjympik>, pk  <p...(a)pk.invalid> wrote:
> >>Lew Pitcher wrote:
>
> >>> On October 3, 2009 08:15, in comp.unix.shell, Danish
> >>> (me.linuxad...(a)gmail.com) wrote:
>
> >>>> Hi,
>
> >>>> Please tell me how to remove the non printing characters from a test
> >>>> file.
>
> >>> cat test_file | tr -cd '[:print:]'
>
> >>Careful with that one...it will remove newlines! Maybe this:
>
> >>tr -cd '[:print:]\n' < test_file
>
> > The OP said he wanted to remove non-printing characters...
>
> Yes true. My suspicion came from the fact that he was trying to use dos2unix
> to do that, which could suggest the file is mostly a text file with some
> spurious non-printing characters (other than \n). But you're right, whether
> \n (and perhaps \t and a few others) should be included among
> the "non-printing" characters only the OP can tell.

Hi All,

What i wanted was to remove the ^M (carriage return) from the text
files in the production server. I went thru the command pk provided
and it worked well. I'm sorry I dont have much knowledge about non
printing characters to talk about. This all that I can tell you.

Regards
From: pk on
dsids wrote:

> Hi All,
>
> What i wanted was to remove the ^M (carriage return) from the text
> files in the production server. I went thru the command pk provided
> and it worked well. I'm sorry I dont have much knowledge about non
> printing characters to talk about. This all that I can tell you.

Then the command you ran removed tabs as well, which might or might not be
ok. To only remove carriage returns, you could have done just

tr -d '\r' < file

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4
Prev: SED help -
Next: AIX iconv question