|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I'm trying to diff files in different directories, but I don't want to
diff everything. The compiler produces subdirectories like debugger, unshared, and profiled. I don't care what's in them, or if the .o files are different. So far I've gotten this far: export SRC=query_E export TGT=query_D find $SRC -name debugger -prune \ -o -name unshared -prune \ -o -name profiled -prune \ -o -name '*.c' -exec diff '{}' `echo {} | tr $SRC $TGT` \; I don't know why tr isn't substituting $SRC for $TGT at all. It just creates "diff query_E/... query_E/..." What am I doing wrong? I looked at someone else's solution which had an exec as follows: -exec diff '{" $TGT The problem is if find goes down more than 1 level, it will not match $TGT anymore. Thanks, Craig |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Fri, 25 Apr 2008 15:24:19 -0700, Craig Hanna wrote:
> I'm trying to diff files in different directories, but I don't want to > diff everything. The compiler produces subdirectories like debugger, > unshared, and profiled. I don't care what's in them, or if the .o files > are different. So far I've gotten this far: > > export SRC=query_E > export TGT=query_D > > find $SRC -name debugger -prune \ > -o -name unshared -prune \ > -o -name profiled -prune \ > -o -name '*.c' -exec diff '{}' `echo {} | tr $SRC $TGT` \; > > I don't know why tr isn't substituting $SRC for $TGT at all. It just > creates "diff query_E/... query_E/..." > > What am I doing wrong? > I looked at someone else's solution which had an exec as follows: -exec > diff '{" $TGT > The problem is if find goes down more than 1 level, it will not match > $TGT anymore. > > Thanks, > Craig There are several difficulties. 'tr' is not the program you want, it does a letter by letter substitution, and you want a word by word change. Most people use "sed" to do this. A second problem is that the name conversion happens *before* the find is run. As echo {} | tr query_E query_D is the same as echo {} | tr E D and there is no E in "{}", this gives {} so your find command is find query_E -name debugger .... -exec diff '{}' '{}' If I were writing this I would probably write it as this, assuming I knew there were no funny characters in the filenames find $SRC -name debugger -prune \ -o -name unshared -prune \ -o -name profiled -prune \ -o -name '*.c' -print | sed "s:$SRC/\(.*\):diff & $TGT/\1:" and when I was happy that this was doing what I wanted, I would repeat the command and put | sh onto the end of it to actually run it. |
|
![]() |
| Outils de la discussion | |
|
|