Discussion:
diff using wildcards
(too old to reply)
Paul F. Johnson
2004-01-20 15:57:40 UTC
Permalink
Hi,

I'm trying to do a diff of two directories, but only on files starting
with an "s"

I'm currently using

diff -u Scribus/scribus/s* Scribus-devel/scribus/s* >sdiff.txt

which just reports

diff : extra operand 'Scribus/scribus/scfonts_ttf.cpp'
diff : Try 'diff --help' for more information

How do I do a diff using wildcards?

TTFN

Paul
Jim Howes
2004-01-20 16:17:29 UTC
Permalink
Post by Paul F. Johnson
Hi,
I'm trying to do a diff of two directories, but only on files starting
with an "s"
I'm currently using
diff -u Scribus/scribus/s* Scribus-devel/scribus/s* >sdiff.txt
which just reports
diff : extra operand 'Scribus/scribus/scfonts_ttf.cpp'
diff : Try 'diff --help' for more information
The wildcards get expanded by the shell, so diff sees far more files
than it's expecting, and doesn't know how you want the file list
combined; you could do something like:

rm -f sdiff.txt ; for f in Scribus/scribus/s* ; do XX=`basename $f` ;
diff -u $f Scribus-devel/scribus/$XX >>sdiff.txt ; done

(that was all one line, beware your newsreader's line wrapping)

In english:
Remove the results file; for all files matching BLAH, take just the
filename without the path, and diff the original with BLAH2/{filename},
appending result to results file.

Jim

Of course, there's probably a bazillion more ways to do it, and the
above isn't very resistant to file names with spaces and other special
characters in them (Argh! I hate filenames with spaces, that's what god
invented the _ for...)
Robert Harris
2004-01-20 16:37:51 UTC
Permalink
Post by Paul F. Johnson
diff -u Scribus/scribus/s* Scribus-devel/scribus/s* >sdiff.txt
How do I do a diff using wildcards?
Paul
diff -u --from-file=Scribus/scribus Scribus-devel/scribus/s* >sdiff.txt
Brian Gough
2004-01-20 16:38:16 UTC
Permalink
Post by Paul F. Johnson
I'm trying to do a diff of two directories, but only on files starting
with an "s"
diff -x '[^s]*' dir1 dir2

See chapter 4 of the diff manual ("Comparing directories") for details.
http://www.network-theory.co.uk/diff/manual/
--
Brian Gough

Network Theory Ltd -- Publishing Free Software Manuals
15 Royal Park
Bristol BS8 3AL
United Kingdom

Tel: +44 (0)117 3179309
Fax: +44 (0)117 9048108
Web: http://www.network-theory.co.uk/
Continue reading on narkive:
Loading...