LinuxQuestions.org
Help answer threads with 0 replies.
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-20-2009, 05:32 AM   #1
akkigupta
LQ Newbie
 
Registered: Jul 2009
Location: Bangalore
Posts: 2

Rep: Reputation: 0
Comparing 2 files in linux makefile system


Hi all,

I want to copy one file from source folder to destination folder using Makefile in Linux enviornment. I want to make sure it happens only if destination folder doesnt have updated file.

Can you guide me how can i compare 2 files in makefile?
 
Old 07-20-2009, 05:53 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Hi,

Welcome to LQ!

And while this certainly could be achieved with make ...
why don't you use a tool that's designed for that task,
like for example rsync or unison?



Cheers,
Tink
 
Old 07-20-2009, 05:59 AM   #3
akkigupta
LQ Newbie
 
Registered: Jul 2009
Location: Bangalore
Posts: 2

Original Poster
Rep: Reputation: 0
Hi Tinkster, Thanks for your reply.

I was seeing the usage of the tools you mentioned. But it doesnt seems applicable to my enviornment. My enviornment already has the makefile system, which we are using to build a binary. In that we require to copy certain configuration file, if there is any updation. So looking for such kind of solution.

Can you tell me how we can achieve the same ?
 
Old 07-21-2009, 03:47 AM   #4
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by akkigupta View Post
Hi all,

I want to copy one file from source folder to destination folder using Makefile in Linux enviornment. I want to make sure it happens only if destination folder doesnt have updated file.

Can you guide me how can i compare 2 files in makefile?
After all make run regular commands.
You can use
Code:
cmp $(SRC_FILE) $(DST_FILE) 2>/dev/null || cp -f $(SRC_FILE) $(DST_FILE)
 
  


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
comparing directories and files crazy8 Linux - Newbie 4 01-16-2008 11:33 AM
Perl: comparing 2 files UnixKiwi Programming 14 07-05-2007 04:27 AM
How to redirect output object files using a linux kernel Makefile? archieval Linux - Newbie 0 06-28-2007 01:14 AM
Using diff for comparing 2 files beep Programming 5 01-21-2005 01:51 PM
Comparing 2 Files xianzai Programming 2 05-23-2004 12:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration