Unlink and copy actual file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unlink and copy actual file
# 1  
Old 05-27-2011
Unlink and copy actual file

Hello,
I have a set of directories, which has inside them, symbolic links to some files. What i would like to do is to covert the links into actual files, i.e. remove the link and copy the actual file here...

I tried to see unlink command but i think all it does is delete the link, is there anything that would transform the link to the actual copy ?

Thanks in advance
# 2  
Old 05-27-2011
Code:
 find /home/user/c_test/ -type l |while read link; do
> b=`basename $link`
> d=`dirname $link`
> cp $link $d/temp
> rm $link
> mv $d/temp $link

This worked for me, I was trying to copy the file in temp name (which will copy the content), then remove the link and copy the temp back in the link name.
This User Gave Thanks to kumaran_5555 For This Post:
# 3  
Old 05-27-2011
Thanks Kumaran, for the timely reply, it worked perfectly. exactly what i wanted to do
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX/Linux - awk - displaying unxpected ! character when viewed in mail; but not in actual file

Greetings Experts, I am on AIX using ksh; I am processing the input files and generating a awk_output.txt file using AWK. By reading that awk_output.txt file, I am building a output.html file which is cat and then fed to /usr/sbin/sendmail .When the shell script is triggered through command... (2 Replies)
Discussion started by: chill3chee
2 Replies

2. Shell Programming and Scripting

Unlink multiple files

I wish to unlink multiple links, but man pages shows unlink - call the unlink function to remove the specified file let's linked are in number sequence and I'm doing unlink `echo {1..500}` This fails.. Is their any other command to execute it or I need to call the unlink function that... (1 Reply)
Discussion started by: posix
1 Replies

3. Shell Programming and Scripting

Actual SQL instead of using a file from within a shell script

I am very noobish to UNIX, our guy is on vacation so I am trying to take up some slack while he is away. Typically when we use sql from within a shell script, we do so from a file containing the sql. Example: $ORACLE_HOME/bin/sqlplus $ORA_DBCU/$ORA_DBCP @${cron_dir}/${report_file}.sql ... (10 Replies)
Discussion started by: biobill
10 Replies

4. Shell Programming and Scripting

need to add user from command prompt not to open actual file

Here is my script which gives the below output when I run.First it will display the list of all groups and then ask for enter the group name and after it will ask for contribuotors or users then I will add contribuotirs or users and it will show the list of all users associated with that group but... (3 Replies)
Discussion started by: rohit22hamirpur
3 Replies

5. Solaris

How to see actual filename that File Descriptor is pointing to for a given processID?

Using lsof command I was able to query all Regular Files opened for write. A specific processID related output shows some FileDescriptors(FD 45 in second output 45w) pointing to real file. But most of the FDs(1, 2, 5 in first output and 31,29,10 in second output) are pointing to root of the disk... (19 Replies)
Discussion started by: kchinnam
19 Replies

6. Shell Programming and Scripting

Open the file and replace the variable with actual value

Hi, i have a sql file named sample.sql. The query is given below. select count(*) from $TABLE_NAME In the main script, i am sourcing this sql. I need to replace the $TABLE_NAME with actual value, before running the query. How can i achieve that? The logic i tried is given below:... (3 Replies)
Discussion started by: bharathappriyan
3 Replies

7. UNIX for Dummies Questions & Answers

Searching list of entries in file for actual files in dir

Hi all, I have a file entries.txt that contains a number of entries all on seperate lines e.g. test1 test2 test3 test4 Then in a directory called /TestFiles I have a number of files that could contain the above text in the file name e.g. qwertytest1.csv qwertytest2.csv... (2 Replies)
Discussion started by: not4google
2 Replies

8. Shell Programming and Scripting

perl unlink question

Hi, I have a two lines of code both intend to perform the same task. unlink $CtrFile; system ("rm $CtrFile"); Both of which try to delete a certain file. However when I use the unlink command the file does not get deleted. When I use the "rm" system... (2 Replies)
Discussion started by: jerardfjay
2 Replies

9. UNIX for Dummies Questions & Answers

mv: cannot unlink ????

Hello all, I have a script which runs every 15 minutes and moves all but latest 10 files from a directory (A) to Directory (B). Most of the times this job runs fine but sometimes it is giving "mv: cannot unlink {Target Directory name } : Permissions denied." Any help about this error msg... (1 Reply)
Discussion started by: super_duper_guy
1 Replies

10. UNIX for Advanced & Expert Users

link and unlink , urgently...

Hi all I did something incorrectly about link command. I try to make a link from a sub-dir to root dir, but I use the following command: link / zzz the result is sub-dir "zzz" was linked to "/" Then I want to remove the "zzz" by using unlink command: unlink zzz It say that "Device... (1 Reply)
Discussion started by: umonk
1 Replies
Login or Register to Ask a Question