LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 10-08-2004, 06:01 AM   #1
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Question Copying linked files, replacing directories in bash scripts?


I have a centrally located folder ($HOME$/my-libs) with all of my 'completed' sources. When I create a new project, I 'lndir' the appropriate source directories into the project folder so that all projects use up to date sources and I have the links there to show me the dependencies.

When I back up a version, I would like to either

1) be able to copy the project folder and have the original files (instead of the links) copied with the folder

2) create a shell script to see which source folders exist in the project folder, and then copy the folders from the central source directory. In case that was not clear:

Suppose there are folders 'ALGORITHM', 'ANALYSIS', and 'FILE' in the source folder. Then suppose there was a project 'APP' that needed 'ALGORITHM', so I would 'lndir' that folder into 'APP/ALGORITHM'. The ideal script would decide "this folder contains 'ALGORITHM', which is also a folder in the source directory, therefore I will replace that folder with the actual one from source directory." Is that possible?

Thanks.
ta0kira
 
Old 10-08-2004, 09:26 AM   #2
christhom
Member
 
Registered: Sep 2004
Distribution: Debian sarge/sid
Posts: 41

Rep: Reputation: 15
Re: Copying linked files, replacing directories in bash scripts?

Quote:
Originally posted by ta0kira

1) be able to copy the project folder and have the original files (instead of the links) copied with the folder
1) is easy. cp -rL. the "-L" flag dereferences the symlinks, following them and copying the actual files.

Quote:

2) create a shell script to see which source folders exist in the project folder, and then copy the folders from the central source directory. In case that was not clear:
This seems to defeat the purpose of using lndir in the first place. But just use simple tests and above cp command.

if [ -d APPS/ALGORITHM ]; then
cp -rL /path/ALGORITHM /path/APP;
fi

But now you're left re-copying every time you change anything in ALGORITHM, not to mention the redundancy. man lndir and read what it says...

HTH
 
Old 10-10-2004, 04:46 AM   #3
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Original Poster
Rep: Reputation: Disabled
Thanks, that is what I was looking for. I figured out the second part yesterday. In the project folders I am leaving the links, but I back up the projects once in a while. When I back one up, I want a (then-current) copy of the actual sources so that the project can be distro'd or put on CD, and I can reproduce the app just from that backup. Thanks again.
ta0kira
 
  


Reply



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
Mount and linked directories ohman Linux - Newbie 3 10-05-2004 06:54 AM
bash scripts and running .sh files xviddivxoggmp3 Programming 9 08-14-2004 05:33 AM
copying a lot of files with bash or terminal. rob-n Linux - Newbie 3 04-13-2004 06:01 PM
Copying directories NetScripter Linux - Newbie 3 05-25-2002 12:48 AM
copying directories jonfa Linux - General 2 11-08-2001 10:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:20 PM.

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
Open Source Consulting | Domain Registration