• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Stream Files and End-of-Line Delimiters, Take Three

    November 15, 2006 Hey, Ted

    I do a bit of development in Cygwin under Windows and then move it to the iSeries using Qshell. It turns out that Qshell doesn’t like the carriage-return/linefeed combination (CRLF) in shell scripts, so I often need to change CRLF to LF–as you wrote about in two previous articles–in bulk. Here are some methods I use to convert end-of-line delimiters in stream files.

    The first method is a simple Perl command.

    perl -i.bak -pe 's/rn/n/g' * 
    

    This command adds the extension .bak to the end of the files and strips the CRLF, putting in LF instead. By using a wildcard, I can convert a whole directory at a time rather than one file at a time. One could just as easily handle a single file by changing the wildcard at the end from * to the name of the file that one wants to convert.

    Another way is to use a Qshell script like this one, which I call dos2unix, after the Linux command of the same name:

    #!/bin/bash 
    
    # Replace CRLF with LF 
    
    E_WRONGARGS=65 
    
    if [ -z "$1" ] 
    then 
    echo "Usage: `basename $0` filename-to-convert" 
    exit $E_WRONGARGS 
    fi 
    
    file="$1" 
    sed 's/rn/n/g' $file > $file.fixed 
    cp -f $file.fixed $file 
    rm -f $file.fixed 
    

    An alternative to sed is tr:

    tr -d 'r' < $file > $file.fixed 
    

    –Buck Calabro

    Thanks, Buck. I appreciate the solutions. Little junk like this tends to eat up my day.

    –Ted

    RELATED STORIES

    EDTF and End-of-Line Delimiters

    EDTF and End-of-Line Delimiters, Take Two

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags:

    Sponsored by
    ARCAD Software

    Embrace VS Code for IBM i Development

    The IBM i development landscape is evolving with modern tools that enhance efficiency and collaboration. Ready to make the move to VS Code for IBM i?

    Join us for this webinar where we’ll showcase how VS Code can serve as a powerful editor for native IBM i code and explore the essential extensions that make it possible.

    In this session, you’ll discover:

    • How ARCAD’s integration with VS Code provides deep metadata insights, allowing developers to assess the impact of their changes upfront.
    • The role of Git in enabling seamless collaboration between developers using tools like SEU, RDi, and VS Code.
    • Powerful extensions for code quality, security, impact analysis, smart build, and automated RPG conversion to Free Form.
    • How non-IBM i developers can now contribute to IBM i projects without prior knowledge of its specifics, while ensuring full control over their changes.

    The future of IBM i development is here. Let ARCAD be your guide!

    Watch Now

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Sponsored Links

    Patrick Townsend & Associates:  Alliance AES/400 - database field encryption
    New Generation Software:  Leading provider of iSeries BI and financial management software
    COMMON:  Join us at the Annual 2007 Conference & Expo, April 29 - May 3, in Anaheim, California

    Online Backups Business Treating EVault Well The State of the System i: The Analysts Speak

    Leave a Reply Cancel reply

Volume 6, Number 41 -- November 15, 2006
THIS ISSUE SPONSORED BY:

T.L. Ashford
iTera
WorksRight Software

Table of Contents

  • Create Database Files from SQL Queries
  • Stream Files and End-of-Line Delimiters, Take Three
  • Admin Alert: Three Steps to Mapping iSeries Data to a Windows Network Drive
  • Get Creative Using the SQL Database Exit Point
  • Finding Large IFS Directories
  • Admin Alert: The Rule of Fours for i5 Test Environments

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Liam Allan Shares What’s Coming Next With Code For IBM i
  • From Stable To Scalable: Visual LANSA 16 Powers IBM i Growth – Launching July 8
  • VS Code Will Be The Heart Of The Modern IBM i Platform
  • The AS/400: A 37-Year-Old Dog That Loves To Learn New Tricks
  • IBM i PTF Guide, Volume 27, Number 25
  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle