Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here you go:</p> <pre><code>find ./build/.jenkins/jobs/* | grep -i 'someotherfiles.blah' | cut -d / -f 5- | rsync -v -r --exclude-from=- ./build/.jenkins/jobs/ ./output </code></pre> <p>In steps, this is what is happening:</p> <pre><code> find ./build/.jenkins/jobs/* </code></pre> <p>This provides a list of the directories / files in the path specified. the output of it is </p> <pre><code>./build/.jenkins/jobs/Job1 ./build/.jenkins/jobs/Job1/config.xml ./build/.jenkins/jobs/Job1/someotherfiles.blah ./build/.jenkins/jobs/Job2 ./build/.jenkins/jobs/Job2/config.xml ./build/.jenkins/jobs/Job2/someotherfiles.blah ./build/.jenkins/jobs/Job3 ./build/.jenkins/jobs/Job3/config.xml ./build/.jenkins/jobs/Job3/someotherfiles.blah </code></pre> <p>We then pipe it to the grep command, where we can put in any pattern we want to filter on. In my example, I am grepping to exclude someotherfiles.blah</p> <pre><code>find ./build/.jenkins/jobs/* | grep -i 'someotherfiles.blah' </code></pre> <p>output is </p> <pre><code>./build/.jenkins/jobs/Job1/someotherfiles.blah ./build/.jenkins/jobs/Job2/someotherfiles.blah ./build/.jenkins/jobs/Job3/someotherfiles.blah </code></pre> <p>now rsync will take from stdin the list of patterns to exclude from its sync. It needs to have the paths relative to its src argument, however, so we cut off the first few directories from out list.</p> <pre><code>find ./build/.jenkins/jobs/* | grep -i 'someotherfiles.blah' | cut -d / -f 5- </code></pre> <p>output:</p> <pre><code>Job1/someotherfiles.blah Job2/someotherfiles.blah Job3/someotherfiles.blah </code></pre> <p>Now we pipe it to it rsync using the --exclude-from=- argument. This will tell it to exclude the files from stdin.</p> <pre><code>find ./build/.jenkins/jobs/* | grep -i 'someotherfiles.blah' | cut -d / -f 5- | rsync -v -r --exclude-from=- ./build/.jenkins/jobs/ ./output </code></pre> <p>output</p> <pre><code>building file list ... done Job1/ Job1/config.xml Job2/ Job2/config.xml Job3/ Job3/config.xml sent 318 bytes received 104 bytes 844.00 bytes/sec total size is 15 speedup is 0.04 </code></pre> <p>This solution is using grep to find a list of files to EXCLUDE from rsync. It is possible you want a grep expression to exclusively INCLUDE only certain files. You can do this too using the --include-from=- argument. There is one more change also. Here is the full code for this, which copies ONLY the config.xml files</p> <pre><code>find ./build/.jenkins/jobs/ | grep -i 'config.xml' | cut -d / -f 5- | awk -F/ '{print; while(/\//) {sub("/[^/]*", ""); print}}'| rsync -v -r --include-from=- --exclude='*' ./build/.jenkins/jobs/ ./output </code></pre> <p>When you add things to the --exclude list, rsync will not search any subdirectories of the list. Clearly we don't want this since we have config.xml files in our Job1,2,3 folders! So we use awk to add to our output the parent directories that we want to search config.xml files for.</p> <p>After that, we tell rsync to --include-from our stdin and exclude everything else ('*')</p> <p>The paths above use relative paths, if you use absolute paths, modify the paths as necessary and make sure the -f argument in the cut commands chooses the right token number to cut up to.</p> <p>anyways, save these commands up in a .sh file and you should have a handy little utility to use.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload