Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm looking for a way to do something like this:

cp -R jquery-ui-1.10.3/themes/base/minified ui

..but to let it match all files in the minified folder (and only it's root) and except all subdirectories/files.

The folder has 1 subfolder called images, but want to exclude cases in the future when it might have more directories.

I could just remove the images directory afterwards, but it might give problems if more subfolders arise in future releases of jquery-ui.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

All you need to do is not to pass the -R flag:

cp jquery-ui-1.10.3/themes/base/minified/* ui

From man cp:

   -R, -r, --recursive
          copy directories recursively

By default, cp does not recurse into sub directories and only copies files.


If for whatever weird reason the default behavior of cp fails, you can always use find:

find -type f jquery-ui-1.10.3/themes/base/minified/* -exec cp "{}" ui \;
share|improve this answer
    
Sorry; I forgot to note I'm using OSX. I get an error while using cp -R jquery-ui-1.10.3/themes/base/minified/* ui gives usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory. –  Allendar May 19 '13 at 17:41
    
@Allendar Ummm... why are you giving the -R flag? The whole point was to not pass the -R flag. This operation does not require the -R flag, it is an -R flag-less situation. (sorry re-watched the parrot sketch recently). –  terdon May 19 '13 at 17:45
    
Correction; cp jquery-ui-1.10.3/themes/base/minified/* ui gives that usage-message. –  Allendar May 19 '13 at 17:47
1  
Does ui exist and is it a directory? Do you have your paths correctly? Do both source and target directories exist? Are you copy/pasting the exact command you ran or could there be a syntax error I don't see? What I am suggesting here is very basic cp usage. Don't have access to a mac at the moment but the OSX man page agrees with me. –  terdon May 19 '13 at 17:53
    
I just tested it (on OS X) and confirmed it working. No idea why you'd get a usage message unless ui wasn't a directory (or not existing at all). In that case you do get the OP's error. –  slhck May 19 '13 at 19:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.