Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-24-2011, 03:20 PM   #1
Registered: Jan 2011
Location: Dhaka
Posts: 80

Rep: Reputation: 1
Moving files and directories except few


I made a terrible mistake while move sites of one server to another. We created virtualhosts in the new server using virtualmin. But while restoring files from old server to new server, I mistakenly copied all files in "/home/VIRTUALHOSTS-NAME/" instead of "/home/VIRTUALHOSTS-NAME/public_html". Now I had to move all files from the home directory of the virtualhosts to the public_html directory except few default folders like: fcgi-bin, public_html, awstats,cgi-bin etc. Can this be automated with a shell script or any command with pipe?

Thanks for your help in advance.
Old 10-24-2011, 03:44 PM   #2
Registered: Apr 2009
Location: Paris, France
Distribution: Fedora 12 Constantine
Posts: 142

Rep: Reputation: 44
rsync should do what you need. Read up on
man rsync
to understand the syntax you will need.
Old 10-25-2011, 06:49 AM   #3
Registered: Jan 2011
Location: Dhaka
Posts: 80

Original Poster
Rep: Reputation: 1
shopt -s extglob
mv !(fcgi-bin|public_html|awstats|cgi-bin|...) public_html
That resolves it. Can't use rsync because the folder structure in source machine is different.


move, shell scripting

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving directories to new directories keysorsoze Linux - Newbie 2 03-31-2006 07:14 PM
Moving or copying a directory into multiple directories oadvantage Linux - Newbie 3 03-07-2006 03:47 AM
An easy way of moving /home and other directories 1kyle SUSE / openSUSE 1 09-23-2005 02:53 AM
moving directories with FTP illiniguy3043 Linux - Software 2 07-08-2004 12:37 AM
Moving directories to their own partitions bxb32001 Debian 7 12-08-2003 06:40 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:43 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration