I am trying to find duplicates on a disk containing all my pictures. for this purpose I created a file containing potential duplicates (using some exif and check sum properties but this is not the purpose of the question).
I have created a file using this format (using exiftool mainly and little formatting):
./PICTURES_archives/a organiser/Ipad/823WGTMA/IMG_1777.JPG <--> ./PICTURES_archives/a organiser/Ipad/965YOKDJ/IMG_2346.JPG
./PICTURES_archives/a organiser/iCloud Photos/My Photo Stream/IMG_0954.JPG <--> ./Pictures A classer/Iphone 5S Icloud/IMG_0954.JPG
I created the following awk
script to show the same output in a different format:
awk -F'<-->' 'BEGIN {
format1= "%25s %-50s\n";
format2 = "%-50s %s\n";
compt=1
}
{
compt++;
split($1,a,"/");
split($2,b,"/");
longb=length(b);
longa=length(a);
long=longb;
if (longa>longb) long=longa;
for(i=1; i<=long;i++) {
if(a[i]==b[i]) printf format1," ", a[i] ;
else printf format2, a[i],b[i]
}
print "\n"
}' identical.txt
More readable to me. the output is :
file a | common path | file b |
---|---|---|
. | . | |
PICTURES_archives | ||
a organiser | ||
Ipad | ||
823WGTMA | 965YOKDJ | |
IMG_1777.JPG | IMG_2346.JPG | |
. | . | |
PICTURES_archives | Pictures A classer | |
a organiser | Iphone 5S Icloud | |
iCloud Photos | IMG_0954.JPG | |
My Photo Stream | ||
IMG_0954.JPG |
QUESTION : I would like to put color for the output when the information for file a and b are different.
I tried to end the function with
printf format2, "\033[33m"a[i] "\033[0m","\033[33m"b[i] "\033[0m"
but it shows me the following output
ESC[33m823WGTMAESC[0m ESC[33m965YOKDJESC[0m
ESC[33mIMG_1777.JPG ESC[0m ESC[33mIMG_2346.JPGESC[0m
the ESC[33m is not interpreted as color.
Any tips?
OS: Darwin macOS Big Sur
od
show ascii values in a spaced-out format -- I don't know anything that would render precisely "ESC[".<-->
as the separator was a good way to do it? This looks like an XY Problem to me.less
will show them if you don't use-R
. Tryprintf "\033[33m foo \033[0m\n" | \less
. Ajo, is that what you are using? Does usingless -R
solve it for you or do you need more?