November 21, 2024, 11:14:16 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: cp command or mv or ?  (Read 8323 times)

Offline craig_linuxsolved

  • New Member
  • Posts: 1
cp command or mv or ?
« on: June 27, 2009, 03:17:02 PM »
I've tried using cp to copy the contents of one directory to another and it won't drop/stop executing in interactive mode

I use the -Rfu

I want it to copy all the contents from folder X to folder Y replacing any file that is older with the newer file and to do this to all files at all levels under Y

Or can I or should I use a different linux command like "mv" and if so how.

I'm trying to update a blog engine.

Ok I've waiting all day for a response of some kind

There's got to be a command that will rewrite the contents of one folder and all it's sub folders to a an existing folder, updating files with newer dated files of the same name and adding and files not found in the destination folder. 

Is that clearer to anyone?

I don't see a recursive option in the "mv" command or is that automatic

anyone?
« Last Edit: June 27, 2009, 10:59:47 PM by craig_linuxsolved »

Offline Yogesh

  • New Member
  • Posts: 1
Re: cp command or mv or ?
« Reply #1 on: June 29, 2009, 07:17:25 AM »
use mv -Rf olddirname newdirname.

Offline eth1

  • New Member
  • Posts: 1
Re: cp command or mv or ?
« Reply #2 on: July 03, 2009, 06:21:59 PM »
I was checking the man page and cp does have an argument to provide an answer for the overwrite question.

cp -pv --reply=yes file folder/

Code: [Select]
[root@dev]# cp -pv --reply=yes new test/
`new' -> `test/new'

This will do the trick.

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
Re: cp command or mv or ?
« Reply #3 on: October 29, 2009, 03:13:19 PM »
The reason why this happens most of the time is because of your shell has an alias  for ls.

Do this command:
# alias
(There's an -i switch there)

So if you want to keep your alias, specify fullpath to cp command and supply switches yourself
# /bin/cp -av /source/directory /destination/directory (EXample only)