Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website and Server Administration Forum


You are currently viewing our Website and Server Administration Forum as a guest. Please register to participate.
Login



Reply
SSH moving all files in a folder to a folder inside the folder ! ! !
Old 03-27-2010, 03:59 PM Exclamation SSH moving all files in a folder to a folder inside the folder ! ! !
Experienced Talker

Posts: 49
Trades: 0
Hi,
so I have a folder on my server called /admin/

I want to have all the files and folders in the admin directory to be located at

/admin/SED/

any idea how I can do this?

I know I could use the move command, but not will *.* as it would try to move the SED/ folder into itself?

Please send the command I can use to do this, it would really help !
dimensio is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-27-2010, 05:50 PM Re: SSH moving all files in a folder to a folder inside the folder ! ! !
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Code:
cd /
mkdir /admin/SED
mv /admin/* /admin/SED
And don't worry. The system is not that stupid.
Example below:
Code:
tmo@NAS:~$ mkdir demo
tmo@NAS:~$ mkdir demo/second
tmo@NAS:~$ cp *.flv demo
tmo@NAS:~$ ls demo
Trentemoeller - Moan.flv        second     elmut fritz - Ca m'??nerve.flv  
tmo@NAS:~$ mv demo/* demo/second/
mv: cannot move `demo/second' to a subdirectory of itself, `demo/second/second'
tmo@NAS:~$ ls demo
second
tmo@NAS:~$ ls demo/second/
Trentemoeller - Moan.flv        elmut fritz - Ca  m'??nerve.flv
And by the way, using an
Code:
mv *.* destination
on a linux machine could not have the effect you think.
It would only move files that have a name.extension files and directories.
If you want to include everything, use "*".

Better yet, do not use "mv", but "tar".
If you have a hidden file or directory in your admin folder, it won't be moved with a "mv".

Tar being an archive utility will backup your files and directory, even hidden.
Code:
tmo@NAS:/home/tmo$ rm -rf demo
tmo@NAS:/home/tmo$ mkdir demo
tmo@NAS:/home/tmo$ cp *.flv demo/
tmo@NAS:/home/tmo$ touch demo/.secret
tmo@NAS:/home/tmo$ ls -lah demo
total 18M
drwxr-xr-x   2 tmo webdev 4.0K Mar 27 22:55 .
drwxr-xr-x 139 tmo webdev  12K Mar 27 22:55 ..
-rw-r--r--   1 tmo webdev    0 Mar 27 22:55 .secret
-rw-r--r--   1 tmo webdev  11M Mar 27 22:55 Trentemoeller - Moan.flv
-rwxr--r--   1 tmo webdev 7.3M Mar 27 22:55 elmut fritz - Ca m'??nerve.flv
tmo@NAS:/home/tmo$ tar cvf backup.tar demo/
demo/
demo/Trentemoeller - Moan.flv
demo/.secret
demo/elmut fritz - Ca m'\303\251nerve.flv
tmo@NAS:/home/tmo$
See, the ".secret" is included in the archive, and as a bonus, the permissions and ownership on the file are saved too.
To restore them, simply:
Code:
tmo@NAS:/home/tmo$ mkdir demo2
tmo@NAS:/home/tmo$ cd demo2
tmo@NAS:/home/tmo/demo2$ tar xvpf ../backup.tar
demo/
demo/Trentemoeller - Moan.flv
demo/.secret
demo/obama.flv
demo/elmut fritz - Ca m'\303\251nerve.flv
tmo@NAS:/home/tmo/demo2$ ls -lah
total 20K
drwxr-xr-x   3 tmo webdev 4.0K Mar 27 22:58 .
drwxr-xr-x 140 tmo webdev  12K Mar 27 22:58 ..
drwxr-xr-x   2 tmo webdev 4.0K Mar 27 22:55 demo
tmo@NAS:/home/tmo/demo2$ ls -lah demo/
total 18M
drwxr-xr-x 2 tmo webdev 4.0K Mar 27 22:55 .
drwxr-xr-x 3 tmo webdev 4.0K Mar 27 22:58 ..
-rw-r--r-- 1 tmo webdev    0 Mar 27 22:55 .secret
-rw-r--r-- 1 tmo webdev  11M Mar 27 22:55 Trentemoeller - Moan.flv
-rwxr--r-- 1 tmo webdev 7.3M Mar 27 22:55 elmut fritz - Ca m'??nerve.flv
tmo@NAS:/home/tmo/demo2$
__________________
Only a biker knows why a dog sticks his head out the window.

Last edited by tripy; 03-27-2010 at 06:02 PM..
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Reply     « Reply to SSH moving all files in a folder to a folder inside the folder ! ! !
 

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11401 seconds with 12 queries