LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-06-2009, 07:32 AM   #1
kukata
LQ Newbie
 
Registered: May 2009
Posts: 2

Rep: Reputation: 0
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.
 
Old 05-06-2009, 07:50 AM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,704
Blog Entries: 1

Rep: Reputation: 220Reputation: 220Reputation: 220
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
 
Old 05-06-2009, 07:53 AM   #3
kukata
LQ Newbie
 
Registered: May 2009
Posts: 2

Original Poster
Rep: Reputation: 0
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~
 
Old 05-06-2009, 11:45 AM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,458

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
Quote:
Originally Posted by kukata View Post
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).
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to tell bash to move files to another folder? hq4ever Linux - Newbie 10 12-30-2010 03:15 AM
BASH search and move batches smudge|lala Linux - General 3 03-06-2009 04:49 PM
Bash script: Move files, ignore case Fredde87 Linux - Software 3 09-03-2008 03:34 AM
Bash development - move chmod options to bash jhwilliams Programming 9 06-26-2007 12:13 PM
After a piece of software/a bash script to mass-move files [Fedora Core 6] Alux Linux - Desktop 3 11-23-2006 02:33 PM


All times are GMT -5. The time now is 12:14 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration