• 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
    Manta Technologies

    The Leader in IBM i Education!
    Need training on anything i?
    Manta is all you need.

    Save 30% During Manta’s Year-End Sale!

    Sale ends January 31.

    130 courses and competency exams on:
    · IBM i operations
    · System Management and Security
    · IBM i Programming Tools
    · Programming in RPG, COBOL, CL, Java
    · Web Development
    · SQL, DB2, Query

    Product features:
    · Runs in every popular browser
    · Available 24/7/365
    · Free Student Reference Guides
    · Free Student Administration
    · Concurrent User License
    · Built-In IBM i Simulator

    You can download our 200-page catalog and take sample sessions at MantaTech.com.

    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

  • N2i Gains Traction Among IBM i Newbies
  • Realizing The Promise Of Cross Platform Development With VS Code
  • 2023 IBM i Predictions, Part 3
  • Four Hundred Monitor, January 25
  • Join The 2023 IBM i Marketplace Survey Webinar Tomorrow
  • It Is Time To Have A Group Chat About AI
  • 2023 IBM i Predictions, Part 2
  • Multiple Vulnerabilities Pop Up In Navigator For i
  • Participate In The 2023 IBM i Marketplace Survey Discussion
  • IBM i PTF Guide, Volume 25, Number 4

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 © 2022 IT Jungle

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.