Domanda

So, 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.lst
     else
      echo "$firstResult" "$secondResult" >> notEqual.lst
     fi

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

   done

done

diff -2 equal.lst equal2.lst >> renamedFiles.lst

I am having some difficulty on the 'diff' part, as the output on the 'renamedFiles.lst' shows something like:

3d2 < teste1\TESTE.pub teste2\TEstE.pub

8d6 < teste1\TeStE2.xlsx teste2\testE2.xlsx

So my question is: How can I remove the "3d2" and "8d6" part? Is there a way for me to do so? I wanted to create a report for the differences and it would be "cleaner" if it didn't have those numbers. I know why the numbers are there but is there a way to remove it?

È stato utile?

Soluzione

Use the line formats to specify the exact format desired. For example:

diff -2 "--old-line-format=<%L" "--new-line-format=>%L" "--unchanged-line-format=" equal.lst equal2.lst

Results in bare output like:

>new line
<old line
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top