0

I am using Windows OS.

My program:

#!/bin/bash

    OIFS="$IFS"
    IFS=$'\n'

    find teste1 -type f | while read -r firstResult

    do

      find teste2 -type f | while read -r secondResult

       do

        firstName=${firstResult##*[/|\\]}
        secondName=${secondResult##*[/|\\]}

         if [[ "$( echo "$firstName" | tr [A-Z] [a-z])" == "$( echo "$secondName" | tr [A-Z] [a-z])" ]]; then
          echo "$firstResult" "$secondResult" >> equal
         else
          echo "$firstResult" "$secondResult" >> notEqual
         fi

         if [[ $firstName == $secondName ]]; then
          echo "$firstResult" "$secondResult" >> equal2
         fi

       done

    done

    diff -2 "--line-format=%L" "--unchanged-line-format=" equal equal2 > renamedFiles.lst

    rm equal
    rm equal2
    rm notEqual

Whenever I run this program, it says "diff: conflicting line format". However, it produces the "renamedFiles.lst" and produces exactly the way I want. So, why is it giving me this answer? Can I fix it? It doesn't really affect my program but no one likes seeing warnings / errors on their programs, right? :)

2
  • Why are you calling a bash script a "windows shell" script? Commented Jan 30, 2014 at 16:18
  • Because I am using Windows OS?! Commented Jan 30, 2014 at 16:21

1 Answer 1

1

I think it's because you are using both --line-format (to format all lines) and --unchanged-line-format (to format unchanged lines). I guess diff doesn't define what to do if it gets conflicting format specifiers, so it fails and tells you about it. What you could do is use for example --old-line-format=%L --new-line-format=%L --unchanged-line-format=

Sign up to request clarification or add additional context in comments.

1 Comment

Indeed, THANKS A LOT! :) That did solve it :P Still kept my formatting like I wanted (same as the program I had) but no longer gave out the message. Seems weird though that it doesn't change the format but no longer gives the message either. Either way, thanks for the help, it's solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.