HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: copy sub directories except specific directory
Operating System - Linux
        1839914
        Members
    
    
        2583
        Online
    
    
        110157
        Solutions
    
Forums
        Categories
Company
Local Language
                
                  
                  back
                
        
                
        
                
        
                
        
        
        
                
        
                
        
        
        
                
        
              
              Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
                
                  
                  back
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
                
            
            
                
            
                
            
                
            
                
            
            
                
            
                
            
            
                
            
                
              
            Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
        Information
        Community
Resources
Community Language
        Language
        Forums
Blogs
	
		
			
            
                
            Go to solution
        
            
		
		
			
            	
	
		
        
		
	
	
		Topic Options
			
				
					
	
			
		
	- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2007 04:46 PM
01-15-2007 04:46 PM
			
				
					
					
						Hi all
I usually copy many files in directories.
but I m going to copy that excep for 1 directory.
How can I get the command like that.
==================
dev
drwxr-xr-x 11 root sys 512 9¿ù 26ÀÏ 15:16 devices
drwxr-xr-x 61 root sys 4096 1¿ù 3ÀÏ 17:15 etc
drwxr-xr-x 2 root sys 512 7¿ù 27ÀÏ 20:37 export
dr-xr-xr-x 1 root root 1 12¿ù 27ÀÏ 10:24 home
drwxr-xr-x 10 root sys 512 7¿ù 27ÀÏ 23:13 kernel
drwxr-xr-x 3 root other 512 10¿ù 10ÀÏ 12:12 kwon
==================
I 'm going to copy sub directories except kwon directory.
To notice that so many files in NAS and consider performance first.
If you have an idea additional to fit that,
Post it and reply me , thank you in advance.
					
				
			
			
				
			
			
				
	
			
				
		
			
			
			
			
			
			
		
		
		
	
	
	
I usually copy many files in directories.
but I m going to copy that excep for 1 directory.
How can I get the command like that.
==================
dev
drwxr-xr-x 11 root sys 512 9¿ù 26ÀÏ 15:16 devices
drwxr-xr-x 61 root sys 4096 1¿ù 3ÀÏ 17:15 etc
drwxr-xr-x 2 root sys 512 7¿ù 27ÀÏ 20:37 export
dr-xr-xr-x 1 root root 1 12¿ù 27ÀÏ 10:24 home
drwxr-xr-x 10 root sys 512 7¿ù 27ÀÏ 23:13 kernel
drwxr-xr-x 3 root other 512 10¿ù 10ÀÏ 12:12 kwon
==================
I 'm going to copy sub directories except kwon directory.
To notice that so many files in NAS and consider performance first.
If you have an idea additional to fit that,
Post it and reply me , thank you in advance.
Solved! Go to Solution.
		3 REPLIES 3
	
	            
            
		
		
			
            
                - Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2007 06:49 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2007 07:05 PM
01-15-2007 07:05 PM
			
				
					
						
							Re: copy sub directories except specific directory
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						Hi,
This should work for you:
for rep in `ls ./source/ | grep -v kwon`
do
cp -R ./source/$rep /tmp/target/
done
=> for rep in `ls ./source/ | grep -v kwon`^Jdo^Jcp -R ./source/$rep /tmp/target/^Jdone
Good luck,
Cedric.
		
		
	
	
	
This should work for you:
for rep in `ls ./source/ | grep -v kwon`
do
cp -R ./source/$rep /tmp/target/
done
=> for rep in `ls ./source/ | grep -v kwon`^Jdo^Jcp -R ./source/$rep /tmp/target/^Jdone
Good luck,
Cedric.
	wooot wooot wooot !!!
			
			
				
			
			
			
			
			
			
		- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2007 07:14 PM
01-15-2007 07:14 PM
			
				
					
						
							Re: copy sub directories except specific directory
						
					
					
				
			
		
	
			
	
	
	
	
	
			
				
					
					
						Assuming you want to avoid to copy
the current directory,
you could use a for loop and filter out
in this loop the kwon
for dirlist in $(ls -1p | grep "[a-z][a-z]*" | grep "/" | grep -v kwon)
do
cp $dirlist $target
done
Anyway
There are more ways to do it.
					
				
			
			
				
		
		
	
	
	
the current directory,
you could use a for loop and filter out
in this loop the kwon
for dirlist in $(ls -1p | grep "[a-z][a-z]*" | grep "/" | grep -v kwon)
do
cp $dirlist $target
done
Anyway
There are more ways to do it.
	Look before you leap
			
			
				
			
			
			
			
			
			
		The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
		
	
	
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP
