LinuxQuestions.org
Visit Jeremy's Blog.
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 04-13-2009, 02:27 PM   #1
sharp859
LQ Newbie
 
Registered: May 2008
Posts: 28

Rep: Reputation: 0
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
 
Old 04-13-2009, 02:39 PM   #2
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by sharp859 View Post
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'
 
Old 04-15-2009, 01:48 PM   #3
sharp859
LQ Newbie
 
Registered: May 2008
Posts: 28

Original Poster
Rep: Reputation: 0
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.
 
Old 04-15-2009, 03:17 PM   #4
custangro
Senior Member
 
Registered: Nov 2006
Location: California
Distribution: Fedora , CentOS , RHEL
Posts: 1,979
Blog Entries: 1

Rep: Reputation: 209Reputation: 209Reputation: 209
Quote:
Originally Posted by sharp859 View Post
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
 
Old 04-16-2009, 06:29 PM   #5
sharp859
LQ Newbie
 
Registered: May 2008
Posts: 28

Original Poster
Rep: Reputation: 0
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
 
Old 04-16-2009, 06:41 PM   #6
sharp859
LQ Newbie
 
Registered: May 2008
Posts: 28

Original Poster
Rep: Reputation: 0
Thanks to all

Thanks to all, and I figured out to do using cut command and while loop.

Thanks!
 
  


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
Better way to write this script faizlo Programming 6 01-08-2009 03:25 AM
script to write to a cd nasirdaudahmad Linux - Hardware 3 01-24-2007 12:45 AM
How to write a Script Blake Linux - Software 6 07-18-2004 12:41 PM
how to write this script? MeganageM Linux - Newbie 1 03-10-2004 06:01 PM

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

All times are GMT -5. The time now is 05:29 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
Open Source Consulting | Domain Registration