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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-13-2009, 02:27 PM
|
#1
|
LQ Newbie
Registered: May 2008
Posts: 28
Rep:
|
Please help me write script
Hi I need to have a script which lists all rpm files which are modified.
I need to run
rpm -qa | grep NC |xargs rpm -V
out put=
.......T c /etc/logrotate.d/attivio_adb
.......T c /etc/monit.d/monit_common.conf
.......T /opt/cisco/bin/showver.sh
.......T /etc/logrotate.d/attivio
S.5....T c /opt/attivio/conf/log4j.xml
S.5....T /opt/mgmt/scripts/pfile
.......T c /opt/cic/tomcat/conf/tomcat-users.xml
Now I need only files which are modified i.e files look like below
S.5....T c /opt/attivio/conf/log4j.xml
S.5....T /opt/mgmt/scripts/pfile
any body can give a script.
Thanks!
Praveen
|
|
|
04-13-2009, 02:39 PM
|
#2
|
Senior Member
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
|
Quote:
Originally Posted by sharp859
Hi I need to have a script which lists all rpm files which are modified.
I need to run
rpm -qa | grep NC |xargs rpm -V
out put=
.......T c /etc/logrotate.d/attivio_adb
.......T c /etc/monit.d/monit_common.conf
.......T /opt/cisco/bin/showver.sh
.......T /etc/logrotate.d/attivio
S.5....T c /opt/attivio/conf/log4j.xml
S.5....T /opt/mgmt/scripts/pfile
.......T c /opt/cic/tomcat/conf/tomcat-users.xml
Now I need only files which are modified i.e files look like below
S.5....T c /opt/attivio/conf/log4j.xml
S.5....T /opt/mgmt/scripts/pfile
any body can give a script.
Thanks!
Praveen
|
There is probably a better way...but out of the top of my head....
Code:
rpm -qa | grep NC |xargs rpm -V | grep '^S'
|
|
|
04-15-2009, 01:48 PM
|
#3
|
LQ Newbie
Registered: May 2008
Posts: 28
Original Poster
Rep:
|
Thanks for help.
But I have soem more help I could able to list those files like this using
rpm -qa | grep NC |xargs rpm -V | grep '^S'
S.5....T c /opt/attivio/conf/log4j.xml
S.5....T /opt/mgmt/scripts/pfile
..
Now I need to copy
/opt/attivio/conf/log4j.xml
/opt/mgmt/scripts/pfile
..
so on..
What ever I got listed should copy to another file.
basically
S.5....T c
S.5....T
Should be chomped off and
cp /opt/attivio/conf/log4j.xml /new_directory/
cp /opt/mgmt/scripts/pfile /new_directory/
...
Please let me know how I can go ahead
Thanks in advance.
|
|
|
04-15-2009, 03:17 PM
|
#4
|
Senior Member
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
|
Quote:
Originally Posted by sharp859
Thanks for help.
But I have soem more help I could able to list those files like this using
rpm -qa | grep NC |xargs rpm -V | grep '^S'
S.5....T c /opt/attivio/conf/log4j.xml
S.5....T /opt/mgmt/scripts/pfile
..
Now I need to copy
/opt/attivio/conf/log4j.xml
/opt/mgmt/scripts/pfile
..
so on..
What ever I got listed should copy to another file.
basically
S.5....T c
S.5....T
Should be chomped off and
cp /opt/attivio/conf/log4j.xml /new_directory/
cp /opt/mgmt/scripts/pfile /new_directory/
...
Please let me know how I can go ahead
Thanks in advance.
|
If it's always the last field you can use awk....
Code:
rpm -qa | grep NC |xargs rpm -V | grep '^S' | awk '{print $NF}'
-C
|
|
|
04-16-2009, 06:29 PM
|
#5
|
LQ Newbie
Registered: May 2008
Posts: 28
Original Poster
Rep:
|
Thanks for help but I used another way to get it done.
#!/bin/bash
#set -x
rpm -qa | grep ^NC | xargs rpm -V | grep ^S > /tmp/changeset.dat
cd /tmp/
cat changeset.dat| while read line
do
cut -b 12- > changeset1.dat
done
for file in `cat changeset1.dat`
do
cp -r $file /tmp/test
done
#Remove temp directory at last
rm -rf changeset.dat changeset1.dat
|
|
|
04-16-2009, 06:41 PM
|
#6
|
LQ Newbie
Registered: May 2008
Posts: 28
Original Poster
Rep:
|
Thanks to all
Thanks to all, and I figured out to do using cut command and while loop.
Thanks!
|
|
|
All times are GMT -5. The time now is 05:29 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|