× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Scott, thanks for the tip, I think you hit on the problem. I am in the
process of install GNU utilities for the iSeries and will see what I get wit
h gawk. Thanks, Bob

Bob Schwartz
Director of Technology Services
Glynn County School System
www.glynn.k12.ga.us

Scott Klement wrote:
message: 2
date: Thu, 10 Jan 2008 12:02:36 -0600
from: Scott Klement <midrange-l@xxxxxxxxxxxxxxxx>
subject: Re: qshell - grep removes CR from lines ?

Hi Bob,

Grep is a Unix tool. On Unix systems, text files always end in LF (not
CRLF). Therefore it seems reasonable that the output of grep would
always end in LF rather than CRLF.

I don't understand why you received responses stating that dot doesn't
match a newline..? What they say is certainly true, but I can't see
what it has to do with your question. Maybe I just don't understand
your question?

Aside from that, you're doing some things in your RE that I don't
understand:

a) Using a subexpression -- but never recalling it, therefore it's
pointless.

b) putting .* at the end -- despite that grep doesn't want/need to match
the entire record, and therefore there's no need to say "plus anything
after that."

In other words, unless I'm missing something (certainly possible) your
grep statement really should look like this:

grep '^[0-9]' ${INPUTFILE} > ${OUTPUTFILE}

This basically says "match every record that starts with a number".

If you have gawk installed (from the GNU utilities offered by IBM -- I
think its LPO 5799-PTL, but that's off the top of my head) you could do
the following to add the carriage return back to the record:

grep '^[0-9]' ${INPUTFILE} | gawk '{ print $0 "\r" }' > ${OUTPUTFILE}

That's just what popped into my head -- there are probably lots of other
ways to do it. If you don't want to install gawk, and can't find
another way to do it, you could always write your own (really simple)
utility that adds the CR back to the line... this can easily be done in
ILE RPG or ILE C.


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.