LinuxQuestions.org
Register a domain and help support LQ
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 03-07-2010, 04:49 PM   #1
specialized
Member
 
Registered: Sep 2005
Location: Mar del Plata, Arg
Distribution: Always Slackware
Posts: 220

Rep: Reputation: 34
compare 2 files name


i want to compare 2 name files, for instance.....

i got the package foo1.tgz and the foo2.tgz. and i want a script in bash that detects foo2 is newer than foo1 and delete foo1

can be done?? for manage a collection of slackware packages and bla bla
 
Old 03-07-2010, 05:18 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
sure it's possible by using find and such, but you've not given enough description about what you really want to achieve, how is said script meant to know which files to compare etc.?
 
Old 03-07-2010, 05:20 PM   #3
cloudmilk
LQ Newbie
 
Registered: Dec 2009
Location: Paris, France
Distribution: Debian
Posts: 6

Rep: Reputation: 1
Try :

find $folder -type f -name foo*.tgz -not -newer foo2.tgz -exec ls -l {}\;

Once the result fits your needs, replace
ls -l {} \;
by
rm -f {} \;

That works with 1 file you've just added, but parsing a whole directory and determine the root name of each file to delete older ones is another story, the naming convention must be strict.
Let us know.
 
  


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
compare two files tekmann33 Linux - Newbie 2 10-28-2008 09:09 AM
compare two files haydar68 Programming 8 08-16-2008 04:36 PM
Compare files in specific directory to files on CD szim90 Linux - Newbie 3 02-10-2007 09:39 PM
Compare two files namit Linux - Software 1 12-31-2005 09:10 AM
How do I compare 2 files? linuxhippy Slackware 6 03-26-2005 02:54 AM


All times are GMT -5. The time now is 02:44 AM.

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