LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Please, need a bash script move... (https://www.linuxquestions.org/questions/programming-9/please-need-a-bash-script-move-724119/)

kukata 05-06-2009 07:32 AM

Please, need a bash script move...
 
hello.
can anyone help me i need a bash script which move conents from one directory(directory and files)
/home/temp/*
and put it in to another directory with same stucture(directory and files)
/home/save/

But if file or directory in /home/save/ exist like
mv /home/temp/bla/ /home/save/bla/ only update contesnts inside, or not exist create it.
If files in directory exist : mv /home/temp/bla/file.txt /home/save/bla/file.txt cheate backup or reneme new file-(not replace)
like /home/save/bla/file(1).txt

thanks fore help
p.s Sorry for bad EN.

weibullguy 05-06-2009 07:50 AM

Sounds eerily like homework. Here's how you fish --> http://tldp.org/LDP/abs/html/abs-guide.html. Take a look at Table B-3. Also, take a look at
Code:

man mv

kukata 05-06-2009 07:53 AM

in man mv there is one command chich is --bachup=numbered
but it make directory backup i don't need it.I need only for files.
And --bachup ... make .~1~ .~2~ after file extension and thats not nessesary file.txt.~1~

colucix 05-06-2009 11:45 AM

Quote:

Originally Posted by kukata (Post 3532029)
in man mv there is one command chich is --bachup=numbered
but it make directory backup i don't need it.I need only for files.
And --bachup ... make .~1~ .~2~ after file extension and thats not nessesary file.txt.~1~

Use option -b to backup existing files and option -S to add a custom suffix to the backup file (you can even put the current date as suffix using command substitution and the date command).


All times are GMT -5. The time now is 09:52 AM.