× 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 Klement suggested sed:

> > (3) Is there a Qshell utility that would let me find
> > and replace character sequences in stream files such
> > that I could replace all line feeds (or tabs) with
> > CRLF?
> 
> Uhhh...  There's sed, but the syntax is rather ugly.  You 
> could do this:
> 
>    rm outfile.txt
>    touch -C 1252 outfile.txt
>    grep "." infile.txt | sed "s/$/$(printf \\\\\\r)/g"> outfile.txt

There is also the tr ("translate") utility.  I'm not very experienced with
it, and the man page is not terribly helpful; but I did use it in a script
once where we had to remove line breaks from a file, concatenate the result
with another file, and write the output to a new file.  The code for that
(including comments, and from a Windows command script, ironically enough)
was:

        :: The tr (translate) Unix command with the -d (delete) option
removes the specified character(s); in this
        :: case '\r\n', or carriage return and line feed.  The output from
this is piped into the cat (concatenate)
        :: command, whose "-" parameter means read from standard input -- in
this case the pipe.  The second 
        :: parameter is a file containing the standard end text, and the
whole is redirected to the temporary file
        :: defined above.
        tr -d '\r\n' < "%filename%" |  cat - MeridianEndText.dat >
"%tempFile%"

The -d option deletes the string.  for the substitution we are interested in
here, I _think_ the following should work:

        grep "." infile.txt | tr '\n' '\r\n' > outfile.txt

Test thoroughly before use ;-)  The syntax is slightly easier on the eye
than the sed version, but then again, if the sed version works...

Cheers,

Martin.

-- 
Martin McCallion
Senior Technical Consultant
Misys Wholesale Banking Systems
1 St George's Road, London, SW19 4DR, UK
T +44 (0)20 8486 1951
F +44 (0) 20 8947 3373
martin.mccallion@xxxxxxxxx
www.misys.com

This email and any attachments have been scanned for known viruses using
multiple scanners. We believe that this email and any attachments are virus
free, however the recipient must take full responsibility for virus
checking. This email message is intended for the named recipient only. It
may be privileged and/or confidential. If you are not the intended named
recipient of this email then you should not copy it or use it for any
purpose, nor disclose its contents to any other person. You should contact
the Misys Banking and Securities Division as shown below so that we can take
appropriate action at no cost to yourself. 

Misys Banking and Securities Division, 1 St George's Road, Wimbledon,
London, SW19 4DR, England. Email: banking.postmaster@xxxxxxxxxx Tel: +44 (0)
20 8879 1188 Fax: +44 (0) 20 8947 3373 

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.