So let's say you've got a bunch of files from a big source repository with changes, backed up in a single level directory. These files were from many different folders and different hierarchies in the trunk. You didn't check them in because your work wasn't finished, but now you want to get back to work so you need to know where to put them in the trunk.
You could do use find to locate each file:
find /path/to/trunk -name fileA
find /path/to/trunk -name fileBBut you have all your files in a folder and you want to find all of them at once. This sounds like a job for xargs:
xargs find /path/to/trunk -name '{}'But we have to pipe in the names of the files from our flat directory:
find /path/to/backup -type f | xargs find /path/to/trunk -nameLast problem is that find will produce full paths, and we just want the file name. Here I'm assuming unix style path names //path/to/file for sed (also xargs needs to be told to use just 1 argument per invocation) :
find /path/to/backup -type f -print0 | sed 's/\/\/.*\///g' | xargs -0 -n 1 find /path/to/trunk -nameThe type option tells find to only find files vs. directories. The print0 and 0 options are advocated by xargs. Null terminated arguments are guaranteed to work whereas newline terminated arguments are not.