aus9
Status: Contributor
Joined: 21 Sep 2008
Posts: 278
Location: Australia
Back to top
Posted: Mar 17, 10, 4:58    moving versus copying folder and contents
hi

I plan to have a zip file....no problems there
I plan to unzip it..ok

It will contain a web page...
help.html and it's folder with contents
help.html_files

1) I can successfully copy to a new folder using commands

cp help.html foldername/
and the important one

:: Code ::

cp -a help.html_files/ foldername/


but what I really want to do is a move command on that web page folder

mv -a help.html_files foldername/

does not work

2) as a work a-around I use the copy commands to get them into my target folder
then

:: Code ::

rm help.html_files/*
rmdir help.html-files


3) It needs to be command as I am using a script for remastering an iso.

any clues?

cheers
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 2538
Location: East Coast, West Coast? I know it's one of them.
Back to top
Posted: Mar 17, 10, 9:54    
:: Code ::
mv -f help.html_files/* foldername


assuming your paths are correct that is, ie.

You forgot the wildcard.

or you can simply:

:: Code ::
mv -f help_html_files foldername

which moves folder one inside folder two

also, to rm:

rm -rf help_html_files
aus9
Status: Contributor
Joined: 21 Sep 2008
Posts: 278
Location: Australia
Back to top
Posted: Mar 17, 10, 15:14    
hi

thanks for the quick reply

help.html_files is a folder containing files a and b

my test

:: Code ::

mv -f help.html_files/* target/


moves the enclosed files under target folder but does not move the original folder so
target/a target/b

2) weirdly I just tried

:: Code ::

mv help.html_files/ target/


and this works!

it moves folder and contents maintaining structure to have
newfoldername/help.html_files/ under are the files

thanks

Now will that work for non-Debian distros I wonder?
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 2538
Location: East Coast, West Coast? I know it's one of them.
Back to top
Posted: Mar 17, 10, 15:18    
mv folder/* means: move all contents of folder

mv folder means move the folder and all its contents.

using the slash is not recommended unless you have a positive reason to use it, ie: mv folder target is better than: mv folder/ target/, especially with cp, that can make a real difference in the outcome.

for non interactive scripts, always use mv -f to avoid possible errors or hangs if there is something there already.. cp - f and mv -f means force, don't ask, which for your non interactive parts, you should always use, you yourself as the programmers should already have done whatever tests, if any, required, to make sure it's safe to do those operations.

this will work on any unix system, this stuff is all very old unix, nothing linux specific that I'm aware of, cp, mv, ls, ln.. these are all from way back in the day when you only had x characters allowed in the path/command.
aus9
Status: Contributor
Joined: 21 Sep 2008
Posts: 278
Location: Australia
Back to top
Posted: Mar 18, 10, 15:08    
hi

ok that use of / is because I was doing a lot of grub2 command mode stuff and tab autocompletion is a feature of grub2
(and legacy)

so when I was doing it manually (not a script) I typed help.html_ (and pressed tab key) which gave me the /
then I typed foldername start and pressed tab and got the / at end.


:: Code ::

mv -f help.html_files target


Where target is a foldername

No need to reply if I have finally got it thanks

regards

gordy
Display posts from previous:   

All times are GMT - 8 Hours