Rename link after creation


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Rename link after creation
# 1  
Old 03-31-2015
Rename link after creation

I'm using ln 'myfilepath' 'newlocationpath' to create a hard link to a file, but how can I rename the file afterwards?
# 2  
Old 03-31-2015
Try this:
Code:
oldpath=/myfilepath/
newpath=/new/location

ln -s "$oldpath" "$newpath"
mv "$newpath" "/even/newer/name"

Hope this helps
# 3  
Old 03-31-2015
A "hard link" creates another directory entry for the same, identical file, pointing to the same inode no. and thus inheriting all the meta data as datetime stamps, permissions, etc.
Renaming would just modify a text string in the directory entry. Do as you please.
# 4  
Old 03-31-2015
Quote:
Originally Posted by RudiC
A "hard link" creates another directory entry for the same, identical file, pointing to the same inode no. and thus inheriting all the meta data as datetime stamps, permissions, etc.
Renaming would just modify a text string in the directory entry. Do as you please.
Only if it's within the same file system, such that a rename() system call succeeds.

Otherwise using "mv" to rename a hard link will make a copy of the file and the two links will no longer point to the same file.
This User Gave Thanks to achenle For This Post:
# 5  
Old 03-31-2015
Absolutely. Sorry, escaped my mind.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

/var/adm/messages (insterface turned off/restored) and link up & link down message.

Hi All I am facing an issue with our new solaris machine. in /var/adm/messages Apr 22 16:43:05 Prod-App1 in.routed: interface net0 to 172.16.101.1 turned off Apr 22 16:43:33 Prod-App1 mac: NOTICE: nxge0 link up, 1000 Mbps, full duplex Apr 22 16:43:34 Prod-App1 mac: NOTICE: nxge0 link... (2 Replies)
Discussion started by: javeedkaleem
2 Replies

2. Solaris

/var/adm/messages (interface turned off/restored) and link up & link down message.

Hi All I am facing an issue with our new solaris machine. in /var/adm/messages root@Prod-App1:/var/tmp# root@Prod-App1:/var/tmp# root@Prod-App1:/var/tmp# cat /var/adm//messages Apr 20 03:10:01 Prod-App1 syslogd: line 25: WARNING: loghost could not be resolved Apr 20 08:24:18 Prod-App1... (0 Replies)
Discussion started by: javeedkaleem
0 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Symbolic link not allowed or link target not accessible

Hi everybody, I read about treads realted to this issue but they did not resovle issue given below. Please help me resolve issue given below I have html file under /srv/www/htdocs/actual_folder ls actual_folder/ test.html and following link works... (0 Replies)
Discussion started by: newbielgn
0 Replies

4. Programming

g++ fails to link to static library when compilation and link in single command

Hello All, I've encountered a strange behaviour from g++ that doesn't make sense to me. Maybe you can shed some light on it: I have a bunch of source files and want to compile them and link them with a static library liba.a located in /usr/local/lib64 into an executable Approach 1 works... (0 Replies)
Discussion started by: magelord
0 Replies

5. HP-UX

Symbolic link creation between 2 directories on different machines

I am trying to link 2 directories using: ln -s /net/<hostname>/srcdir/ /net/<desthostname>/dstdir/ I get the following error: ln: /net/<desthostname>/dstdir: Function is not available What is it that i am trying to do wrongly in the above operation? Please use next time code tags (3 Replies)
Discussion started by: Amit Kulkarni
3 Replies

6. Shell Programming and Scripting

mp3 tag/rename based on creation (last modified date)

Arg, I'm trying to figure out how to create a album tag based on the last modified date stamp for files which don't have a corresponding .talk file. IE. 2009 12 10 - Talk Radio.mp3 is how I want them structured, they should all have a corresponding .talk file so my mp3 player can speak the name ie... (0 Replies)
Discussion started by: mrplow
0 Replies

7. UNIX for Dummies Questions & Answers

Difference between hard link and soft link

Hi Experts, Please help me out to find out difference between a hard link and a soft link. I am new in unix plz help me with some example commands ( for creating such links). Regards S.Kamakshi :) (2 Replies)
Discussion started by: kamakshi s
2 Replies

8. Shell Programming and Scripting

problem with link creation!!!!

I have a home directory namely /pto/ppa/ridbmw/etl/ Now i have various directorys below the home directory. For eg from the home directory if i say cd /roddata it changes to that directory. I think its kind of link (I don't know if it's hard or soft). Now i need to create a new directory and... (4 Replies)
Discussion started by: dsravan
4 Replies

9. UNIX for Dummies Questions & Answers

Difference between hard link and soft link in unix

Hi All, Can any one please explain me what is the difference between hard link and soft link in UNIX. Thanks in advance Raja Chokalingam. (2 Replies)
Discussion started by: RAJACHOKALINGAM
2 Replies

10. UNIX for Advanced & Expert Users

Differences between hard link and soft link

Hi all! I'd like to know the differences between hard links and soft links. I've already read the ln manpage, but i'm not quite sure of what i understood. Does a hard link sort of copy the file to a new name, give it the same inode number and same rights? What exactly should I do to do this:... (3 Replies)
Discussion started by: penguin-friend
3 Replies
Login or Register to Ask a Question