- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: script that copies upgraded rpms ?
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2008 04:44 AM
тАО05-26-2008 04:44 AM
script that copies upgraded rpms ?
i have a directory(old_rpms_dir) that contains some rpms.
I have another directory(new_rpms_dir) that contains all of the rpms that "old_rpm_dir" directory contains, as well as some additional rpms
I want a script that copies only those rpms from new_rpms_dir that are also included in in old_rpms_dir
e.g
# ls old_rpms_dir
a.1.rpm b.1.rpm
# ls new_rpms_dir
a.2.rpm b.2.rpm z.0.rpm y.0.rpm
packages a and b are in both directories, so i want that a.2.rpm, b.2.rpm will be copied from new_rpms_dir to a directory "rpms_up2date_dir"
please help
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2008 05:26 AM
тАО05-26-2008 05:26 AM
Re: script that copies upgraded rpms ?
ls -1 /old/ | sort -u > list.old
ls -1 /new/ | sort -u > list.new
while read -r filenew
do
there=$(grep $filenew list.old |wc -l)
if [ $there = 1 ] then
cp $filenew
fi
done < list.new
Some debugging required. Your milage may vary.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2008 05:31 AM
тАО05-26-2008 05:31 AM
Re: script that copies upgraded rpms ?
for i in `ls new_rpms`;do
if [ ! -f old_rpms/${i} ]; then
cp new_rpms/${i} rpms_up2date ;
fi
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2008 06:18 AM
тАО05-26-2008 06:18 AM
Re: script that copies upgraded rpms ?
I'll check the code on tommorow, and will back to the forum with the result.
as my knowledge of Linux and particularly of scripting is almost equal to ZERO, thats why i cant comment at the moment.
Hi Alexander,
> if [ ! -f old_rpms/${i} ]; then
> cp new_rpms/${i} rpms_up2date ;
Alexander, do you think the code will work as I want ? I mean the code will only copy those files(from new_rpms_dir) that are also included in old_rpms_dir ?
my guess says that the code will also copy those additional rpms that are not the part of old_rpms_dir.
if the new_rpm_dir contains gnome-applet-devel but this rpm is not included in old_rpm_dir then I dont want that rpm to be copied from new_rpm_dir to the rpm_up2date_dir
but if new-rpms_dir contains gnome-desktop-devel-3.7.23.67 and the old_rpms_dir contains gnome-desktop-devel-3.7.8.9, then I want this rpm to be copied from new_rpms_dir to the rpm_up2date_dir
Sorry for any inconvenience
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-26-2008 10:44 PM
тАО05-26-2008 10:44 PM
Re: script that copies upgraded rpms ?
I got confused and the code actually checks for the opposite. Simply remove the exclamation mark and it'll do what you want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-27-2008 04:59 AM
тАО05-27-2008 04:59 AM
Re: script that copies upgraded rpms ?
#!/bin/bash
for i in `ls new_rpms`;do
if [ ! -f old_rpms/${i} ]; then
cp new_rpms/${i} rpms_up2date ;
fi
done
will also copy additional(unwanted) files/rpms from new_rpms_dir.
----
#!/bin/bash
for i in `ls new_rpms`;do
if [ -f old_rpms/${i} ]; then
cp new_rpms/${i} rpms_up2date ;
fi
done
when I use the above code(without "!" in 'if' ) then script doesn't copy any single file(do nothing).
Please help
Regards