I have a directory with hundreds of text files and object files. I had a copy of this directory somewhere else and I edited it and recompiled it. the object files are now different, but I want to generate a patch from the text files only. is there a way to do this or do I need to separate them into different folders?
diff -uraN original/ new/ > patch.diff
how can I specify file types in this command?
-X excludes, but I want the opposite of this. I want to exclude everything except .txt files
Did you want one diff per txt?
for f in original/*.txt # for each original
do d=${f#original/} # get base name
diff -uraN "$f" "new/$d" > ${d%.txt}.diff # diff old against new
done
You mention -X
; I'm not sure how diff
implements it, but the bash CLI allows extended globbing.
$: shopt -s extglob
$: ls -l *.???
-rw-r--r-- 1 P2759474 1049089 0 May 10 21:49 OCG3C82.tmp
-rw-r--r-- 1 P2759474 1049089 0 May 11 03:22 OCG511D.tmp
-rw-r--r-- 1 P2759474 1049089 0 May 12 00:03 OCG5214.tmp
-rw-r--r-- 1 P2759474 1049089 0 May 14 09:34 a.txt
-rw-r--r-- 1 P2759474 1049089 0 May 14 09:34 b.txt
$: ls *.!(txt)
-rw-r--r-- 1 P2759474 1049089 0 May 10 21:49 OCG3C82.tmp
-rw-r--r-- 1 P2759474 1049089 0 May 11 03:22 OCG511D.tmp
-rw-r--r-- 1 P2759474 1049089 0 May 12 00:03 OCG5214.tmp