Rename

Thread Solved

Join Date: Aug 2006
Posts: 917
Reputation: linux is an unknown quantity at this point 
Solved Threads: 27
linux's Avatar
linux linux is offline Offline
Posting Shark

Rename

 
0
  #1
Apr 9th, 2008
Is it just me, or is copying then removing the old file a hassle? Why doesn't Linux have a built in rename command for single files / directories?
Toshiba M1151.49 GB DDR-2 RAM1.6 GHz Centrino Duo80GB HDDWindows XP Media Center Edition
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Rename

 
0
  #2
Apr 9th, 2008
Hey there,

You can use "mv" for files and directories.

Perhaps I'm misunderstanding.

Hope that helps

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Rename

 
0
  #3
Apr 9th, 2008
I'm sorry. Looking at your profile, I think you're just kidding You got me

,Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,253
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 542
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is online now Online
Moderator

Re: Rename

 
0
  #4
Apr 13th, 2008
yeah mv
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,297
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 67
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

Re: Rename

 
0
  #5
Apr 15th, 2008
but that moves and renames whilst removing the old file !?
Computers are man's attempt at designing a cat: It does whatever it wants, whenever it wants, and rarely ever at the right time.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,253
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 542
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is online now Online
Moderator

Re: Rename

 
0
  #6
Apr 15th, 2008
switches can change that
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Rename

 
0
  #7
Apr 15th, 2008
I'm pretty mv sure it's cp then rm

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 58
Reputation: omrsafetyo is an unknown quantity at this point 
Solved Threads: 9
omrsafetyo omrsafetyo is offline Offline
Junior Poster in Training

Re: Rename

 
1
  #8
Apr 25th, 2008
No, thats actually exactly wrong.

The mv command does not make a new file. Period. The datablocks holding the information remain unchanged. All that happens is that the entry in the directory file that holds the inode information is copied to the new directory, and then the inode information is removed from the old directory.

To demonstrate this; create a file, and change ownership to someone in your group, but first chmod the file to 600. Chmod the directory the file is located in to 770, and make sure that it is owned by your group and/or you.

Create a new directory (770), with the same ownership. Now, technically, you will not have write access to the file (600 owned by Joe). But, since you have permissions to change the inode information contained in both directory listings, you will be able to run an mv command on the file. You will not, however be able to read from that file to perform the cp command. You can mv, but not cp. You have no access to the stored data, just to the inodes pointing to the data. Therefore, you change the location from which those inodes can be accessed, but do not modify the original file. This is a true mv.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 399
Reputation: eggi will become famous soon enough eggi will become famous soon enough 
Solved Threads: 47
eggi eggi is offline Offline
Posting Whiz

Re: Rename

 
0
  #9
Apr 25th, 2008
Well, not exactly

I threw that one out there without thinking, I'll admit and you are correct in the circumstance that both files are on the same partition.

If you mv /bob/dir1 to /bob/dir2 - assuming /bob is one partition/filesystem containing dir1 and dir2 - then the pointer to inode explanation is correct.

However, if you mv a file from /bob/dir/1 to /joe/dir/1 - assuming /bob is one partition/filesystem and /joe is another partition/filesystem - Unix (at least, Solaris) actually does do a cp and then an rm. The same test you propose will not allow you to mv or cp the file you don't have permissions to access in that situation.

Hopefully, this post is finally resolved. If I'm not mistaken it all started out as a joke

Take care,

Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 58
Reputation: omrsafetyo is an unknown quantity at this point 
Solved Threads: 9
omrsafetyo omrsafetyo is offline Offline
Junior Poster in Training

Re: Rename

 
0
  #10
Jun 3rd, 2008
touche!

I had not thought about that. In that case, you would be correct.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the IT Professionals' Lounge Forum
Thread Tools Search this Thread



Tag cloud for IT Professionals' Lounge
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC