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 |
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.?
|
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. |
All times are GMT -5. The time now is 09:03 AM. |