-- ChristianKahra - 2020-09-08

Find files in subdirectories (e.g. all xci files) and copy them with the relative path to an other location

find . -name '*.xci' | xargs -t -n1 -I SUB cp --parents SUB destination_path/

xargs arguments

  • -t: print the command to stdout, which will be executed (optional for verbosity)
  • -n1: execute the copy command for each file separately (all at the same time would also work)
  • -I SUB: use the string "SUB" as placeholder -> will be replaced by the result of the find command
cp arguments
  • -- parents: copy the file with the relative sub-directory structure to the destination
Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2020-09-08 - ChristianKahra
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2021 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback