Quantcast
Channel: Copy files from a directory to a sub-directory (excluding the sub-directory itself) - Ask Ubuntu
Browsing latest articles
Browse All 10 View Live

Answer by waltinator for Copy files from a directory to a sub-directory...

The simplest way is to move the Child1 directory elsewhere, temporarily:cd Parentmv Child1 ..mv * ../Child1mv ../Child1 .

View Article



Answer by Rooney for Copy files from a directory to a sub-directory...

rsync has an option to exclude files or directories using --exclude option.So in this case I think rsync would be a nice choice.mkdir -p Child1; rsync -av --progress ./* Child1 --exclude Child1

View Article

Answer by Zanna for Copy files from a directory to a sub-directory (excluding...

Less elegant than extglob, but also works...mkdir -p Child1; for i in ./*; do [[ "$i" != ./Child1 ]] && echo cp -vr "$i" Child; donecp -vr ./file1 Child1cp -vr ./file100 Child1cp -vr ./Folder2...

View Article

Answer by Eitan Levine for Copy files from a directory to a sub-directory...

You can use ls to list the contents of "Parent",pipe the result to grep -v to filter out "Child1",and then send the resulting list to cp.This should do the trick: (from within the "Parent" dir)cp `ls |...

View Article

Answer by geirha for Copy files from a directory to a sub-directory...

Assuming you are using bash as your interactive shell, you can enable extglob which allows you to specify "all files except these ones".shopt -s extglobcd Parentcp !(Child1) Child1/

View Article


Image may be NSFW.
Clik here to view.

Answer by hmayag for Copy files from a directory to a sub-directory...

Three excellent answers that demonstrate the flexibility of linux. And it's always a good idea to be familiar with basic command line operations. Personally I prefer a hybrid approach and I try using...

View Article

Answer by llt for Copy files from a directory to a sub-directory (excluding...

find Parent/ -maxdepth 1 -type f | xargs cp -t Parent/Child/This finds all files (excluding directory) inside your Parent/ directory and copies each of those files to Parent/Childfind -type f match...

View Article

Answer by Manuel for Copy files from a directory to a sub-directory...

Try :cd [WhereeverParentLies]cp ./* ./Child1/There will be a message that cp omitted the "Child1" directory.

View Article


Answer by lenz for Copy files from a directory to a sub-directory (excluding...

If the files are actually called 'file1' etc., you can do this:cd Parentcp file* Child1/Otherwise you'll have to list the files in the cp command.

View Article


Copy files from a directory to a sub-directory (excluding the sub-directory...

I have created a folder (directory) named Parent which contains several files (namely file1file2 ... file100) and subdirectories (Folder2, Folder3 etc) and a particular sub-directory named Child1 which...

View Article
Browsing latest articles
Browse All 10 View Live




Latest Images