using tar command

What is the tar command from start to finish to move a directory from one directory to another .

Is the directory you want to move it to on the same server? If so, just use the "mv" command.

Well, you could do something like this:

Create the destination directory, then cd to it. Then do the following:

tar -Ccvf <first_dir> - | tar xvf -

But I prefer this way:

Create the destination directory, then from the source directory, run this:

find . -depth -print | cpio -pdlmv <destination_dir>

:smiley:

Next time you might want to reply to your original thread instead of opening new threads for the same topic as well. Just a suggestion. I'm sure the administrators of the board would thank you for it too. :wink:

doeboy,

Thank you, I will use the reply next time.

hello,

doeboy,

I tried your commands that you gave to me last night and here are the error$ cd /usr/remedy/apps
$ ls
ITServices ITServices.bak
$ pwd
/usr/remedy/apps
$ find .-depth -print | cpio -pdlmv <tmp
find: cannot open .-depth: No such file or directory
ksh: tmp: cannot open
$ find.-depth -print|cpio -pdlmv <tmp
ksh: find.-depth: not found
ksh: tmp: cannot open
$ cd /tmp
$ tar -Ccvf</usr/remedy/apps> -| tar xvf
tar: C: unknown option
Usage: tar {txruc}[vfbFXhiBEelmopwnq[0-7]] [-k size] [tapefile] [blocksize] [exc
lude-file] [-I include-file] files ...
tar: tapefile must be specified with 'f' option
Usage: tar {txruc}[vfbFXhiBEelmopwnq[0-7]] [-k size] [tapefile] [blocksize] [exc
lude-file] [-I include-file] files ...
$
$ tar -Ccvf /user/remedy/apps -| tar xvf-
tar: C: unknown option
Usage: tar {txruc}[vfbFXhiBEelmopwnq[0-7]] [-k size] [tapefile] [blocksize] [exc
lude-file] [-I include-file] files ...
tar: tapefile must be specified with 'f' option
Usage: tar {txruc}[vfbFXhiBEelmopwnq[0-7]] [-k size] [tapefile] [blocksize] [exc
lude-file] [-I include-file] files ...
$

s that I am getting...

Well, I can offer a little assistance with the cpio error:

You need a space between the "." and "-depth"...

I'll help out with the tar solution. I have never seen -C work the way doeboy shows. And I wouldn't add -v to both of the tar jobs. So I would do

mkdir DEST
cd SOURCE
tar cvf - . | ( cd DEST && tar xf -)

These days I probably should switch to:
tar -cvf - . | ( cd DEST && tar -xf -)
but old habits die hard :cool:

Thanks everyone for the help! I got it to work for me!

ok, now for one last question how do I safely remove the contents of the old directory

Let me make myself clear on this I only want to remove the files from that old directory..so I know that I would use the remove command but I want to make sure that I only remove the files and not the directories.

cd to your original directory, and ls -l first to make sure you'll be deleting what you really intend to. Then just "rm *" should remove files, and leave the directories alone.

As for the -C in tar, I guess that parameter is supposed to come after the other tar commands and after the tar file and directories are named. (I know there's some way to do it that looks like what I gave an example for... guess I made a syntactical error... my bad... :stuck_out_tongue: )