Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6971885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:53:49+00:00 2026-05-27T16:53:49+00:00

I’m trying to compare files ignoring carriage returns – which diff -b on any

  • 0

I’m trying to compare files ignoring carriage returns – which diff -b on any other unix performs admirably. But on this AIX 5.3 box:

    tst1:tst2$ od -c testfile
0000000    t   h   i   s  \r  \n   f   i   l   e  \r  \n   h   a   s  \r
0000020   \n   c   a   r   r   i   a   g   e  \r  \n   r   e   t   u   r
0000040    n   s  \r  \n
0000044
tst1:tst2$ od -c testfile_nocr
0000000    t   h   i   s  \n   f   i   l   e  \n   h   a   s  \n   c   a
0000020    r   r   i   a   g   e  \n   r   e   t   u   r   n   s  \n
0000037
tst1:tst2$ diff -b testfile testfile_nocr
1,5c1,5
< this
< file
< has
< carriage
< returns
---
> this
> file
> has
> carriage
> returns
tst1:tst2$

Why so?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:53:49+00:00Added an answer on May 27, 2026 at 4:53 pm

    AIX 5.3 diff does not appear to consider \r as white space. See the following transcript:

    /home/pax: od -c file1
    0000000    h   e   l   l   o  \n   t   h   e   r   e  \n
    0000014
    
    /home/pax: od -c file2
    0000000    h   e   l   l   o  \r  \n   t   h   e   r   e  \r \n
    0000016
    
    /home/pax: od -c file3
    0000000    h   e   l   l   o      \n   t   h   e   r   e     \n
    0000016
    
    /home/pax: od -c file4
    0000000    h   e   l   l   o  \t  \n   t   h   e   r   e  \t \n
    0000016
    
    /home/pax: diff -b file1 file2
    1,2c1,2
    < hello
    < there
    ---
    > hello
    > there
    
    /home/pax: diff -b file1 file3
    <<No output>>
    
    /home/pax: diff -b file1 file4
    <<No output>>
    

    The manpage for diff is a little obtuse on the matter, stating that -b will “cause any amount of white space at the end of the line to be treated as a single newline character …” but does not actually define what it considers to be white space.

    Based on the above transcript, I would gather that spaces and tabs are okay but carriage returns are not.

    One way to get around this will be to remove the carriage returns yourself with a script like:

    #!/usr/bin/ksh
    # crdiff: diffs two files after changing \r\n to \n in both.
    if [[ $# -ne 2 ]] ; then
        echo 'Usage: crdiff <file> <file2>'
        return 1
    fi
    perl -pne 's/\r$//' $1 >/tmp/xyzzy_$$_$1
    perl -pne 's/\r$//' $2 >/tmp/xyzzy_$$_$2
    diff -b /tmp/xyzzy_$$_$1 /tmp/xyzzy_$$_$2
    rc=$?
    rm -f /tmp/xyzzy_$$_$1 /tmp/xyzzy_$$_$2
    return $rc
    

    Alternatively, you could compile the GNU diff utility on your box and insert it into the path before /usr/bin – it appears to have no trouble with \r as white space. In fact, we do exactly that on our AIX4 boxes since diff there doesn’t even pretend to support the -b option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.