LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-01-2008, 11:28 AM   #1
siva19185
LQ Newbie
 
Registered: Jun 2008
Posts: 21

Rep: Reputation: 15
Move directory of files


I have series of files

one.txt two.txt three.txt four.txt and so on into the directory TXT,

I want to move these files to TXT.BACKUP directory like

one.txt.backup two.txt.backup three.txt.backup four.txt.backup....

can anyone guide me......
 
Old 07-01-2008, 12:28 PM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
If you have a backup directory then you probably don't need to rename every file in the backup directory. I would do this.
Code:
cp -R TXT TXT.BACKUP

Last edited by stress_junkie; 07-01-2008 at 12:37 PM.
 
Old 07-01-2008, 12:41 PM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
It will probably work best if you cd into your TXT directory.

Code:
cd TXT
   for file in *.txt; do
   mv "$file" ../TXT.BACKUP/"${file}.backup"
done
Since you want to move them instead of making a copy, adding .backup at the end seems odd to me because the originals are deleted.

After the "in" in the for loop you could have a space separated list of files if there are a handful of particular files that you want to backup:
for file in one.txt two.txt three.txt

Last edited by jschiwal; 07-01-2008 at 12:44 PM.
 
Old 07-02-2008, 03:59 AM   #4
siva19185
LQ Newbie
 
Registered: Jun 2008
Posts: 21

Original Poster
Rep: Reputation: 15
Thank u pals...

It's work very well..

Last edited by siva19185; 07-02-2008 at 04:03 AM.
 
  


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
Need to create a script to move files from one directory to another mustang05 Solaris / OpenSolaris 4 06-16-2006 11:25 AM
loop move files up one directory level Melsync Programming 8 12-19-2005 11:51 PM
how to write a script to move files from one directory to another myeire Linux - Newbie 7 02-25-2005 11:01 AM
denied access to move files into /usr/src directory Larry O Linux - Newbie 4 01-18-2005 12:14 AM
Does anyone know how to move files to a particular directory using shell scripting RowanB Programming 3 11-11-2004 02:46 PM


All times are GMT -5. The time now is 10:39 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration