Login or Register to Ask a Question and Join Our Community


Copy and entire folder except one


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Copy and entire folder except one
# 1  
Old 10-12-2007
Copy and entire folder except one

Hi,

I have a folder named "A".

I want to copy the entire stuff inside it to another location except the folder "B" which is present inside it.

How can it be done?
# 2  
Old 10-12-2007
use GNU tar and look for exclude option
# 3  
Old 10-12-2007
I think the -prune option of the find command will be more useful.

Working on it right now
# 4  
Old 10-12-2007
Quote:
Originally Posted by vibhor_agarwali
Hi,

I have a folder named "A".

I want to copy the entire stuff inside it to another location except the folder "B" which is present inside it.
ksh:

Code:
cp -r A/!(B) dest_dir

bash:

Code:
shopt -s extglob
cp -r A/!(B) dest_dir

zsh:

Code:
setopt extendedglob
cp -r A/^B dest_dir

# 5  
Old 10-12-2007
Hi,

That worked like a charm, was becoming pretty complex with the -prune.

I am new to that type of syntax.

Can you please explain it to me.

Thanks
# 6  
Old 10-12-2007
Quote:
Originally Posted by vibhor_agarwali
[...]
I am new to that type of syntax.

Can you please explain it to me.
Extended globbing (ksh/bash):

Quote:
?(pattern-list) : Matches zero or one occurrence of the given patterns
*(pattern-list) : Matches zero or more occurrences of the given patterns
+(pattern-list) : Matches one or more occurrences of the given patterns
@(pattern-list) : Matches exactly one of the given patterns
!(pattern-list) : Matches anything except one of the given patterns
For zsh check the man pages if you're interested.
# 7  
Old 10-12-2007
Thanks a lot
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script read specific value from files of an entire folder

Hello, I heva a problem creating a script that read specifc value from all the files of an entire folder I have a number of email files into a directory and i need to extrect from each file 2 specific values. After that i have to put them into a new file that looks like that: To: value1 ... (1 Reply)
Discussion started by: ahmenty
1 Replies

2. Shell Programming and Scripting

How to copy files with the same filenames as those in another folder to that same folder?

Hello All A similar question like this was asked before but I need to change part of the question. I've two folders, Folder A contains some image files in 150 subfolders; Folder B contains text files in 350 subfolders. All image files in Folder A have the same filename as the text... (5 Replies)
Discussion started by: chlade
5 Replies

3. Shell Programming and Scripting

Replace character in files of entire folder? sed? or what?

Hello, I do have several files in one folder each file contains measurement data. for each file I would like to replace the character "," by "." ? How can I do this and how can I do this for each file at once? E.G. data_1.dat, data_x.dat (original version) data_1out.dat, data_x_out.dat... (10 Replies)
Discussion started by: rollinator
10 Replies

4. UNIX for Advanced & Expert Users

grep for entire line from a log folder

As per my understanding below mentioned line of code finding a word 'boy' in $ACULOG... num_errors=`grep -i -e fail -e illegal -e exception -e "<E" -e boy $ACULOG | wc -l` if I'm not corerct, please correct me. How I can find entire line like "This is a boy" with something similar as above... (1 Reply)
Discussion started by: heyitsmeok
1 Replies

5. SCO

Make a Copy Entire Hard Disk

Dear All, I have a standalone desktop with SCO Openserver V 5, this is used to control a machine with custom written software. The problem is that the machine manufacturer has closed shop (bankruptcy) and there is no support on software. As a precaution I would want to make a complete backup of... (3 Replies)
Discussion started by: iqbal_siddiqui
3 Replies

6. UNIX for Dummies Questions & Answers

Search for a string and copy the entire line

Hello All, I am after the script or the command which can scan the entire file for a string $PART_ID and when found to extract/copy the corresponding $PART_ID value (e.g THIRE_PTY_SOFTWARE for the 1st occurance of $PART_ID in the attached file) to a file. Appreciate your help. Thanks in... (3 Replies)
Discussion started by: forumthreads
3 Replies

7. Shell Programming and Scripting

Find all text files in folder and then copy to a new folder

Hi all, *I use Uwin and Cygwin emulator. Im trying to search for all text files in the current folder (C/Files) and its sub folders using find -depth -name "*.txt" The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Discussion started by: cgkmal
4 Replies

8. UNIX for Advanced & Expert Users

Auto copy for files from folder to folder upon instant writing

Hello all, I'm trying to accomplish that if a file gets written to folder /path/to/a/ it gets automatically copied into /path/to/b/ the moment its get written. I thought of writing a shell script and cron it that every X amount of minutes it copies these files over but this will not help me... (2 Replies)
Discussion started by: Bashar
2 Replies

9. Linux

Copy entire disk in FC3

I'm running FC3 and I'd like to copy the entire /dev/hda to /dev/hdc, including all the boot info, so that I can boot off of it in case of failure. This will be a one time thing. I'm doing an app upgrade and I'm very afraid the install will go wrong, so I want to be able to quickly be back up in... (11 Replies)
Discussion started by: dangral
11 Replies

10. UNIX for Dummies Questions & Answers

which cmde recommended to copy an entire dty?

Hi, - i am not unix specialist and i would like to save all the contents of a directory containing symbolic links BUT: + i want to get the links within the copy (to be able to restaor them) + i dont want to copy the directories which are pointed to by theses links some advice? what... (4 Replies)
Discussion started by: JAKEZ
4 Replies
Login or Register to Ask a Question

Featured Tech Videos