Share your knowledge at the LQ Wiki.
Go Back > Forums > Other *NIX Forums > AIX
User Name
AIX This forum is for the discussion of IBM AIX.
eserver and other IBM related questions are also on topic.


  Search this Thread
Old 10-30-2012, 05:54 PM   #1
LQ Newbie
Registered: Oct 2012
Posts: 6

Rep: Reputation: Disabled
Function block usage in Shell script to UnInstall Specific packages

Hi Team,

I need to write a shell script to do the following. I'm installting software packages using an install script but, my installation fails because the machine has traces of old installations. So I need verify installed old packages (lslpp) and then uninstall the old packages (installp -u) and then continue to the install script.

Suppose my installation packages are


when I do a lsllp -l | grep 'ABC'

I'll get all the packages installed with ABC in the package name. If the reason code is 0 it means there are traces of previous installations. So before installing the new packages I need to unstall the old packages.

installp -u ABC.lic
installp -u
installp -u ABC.123
installp -u ABC.rte
installp -u ABC.jrte

But my problem is not every machine will have all the above packages installed. Some machine might have only packages ABC.lic and while other might have ABC.rte and ABC.jrte. or some machine might have only ABC.jrte

So I need to identify exactly what packages are installed and just uninstall only those packages. I cannot use installp -u *ABC* as that might uninstall packages related to antoher software package.

Instead of writing lengthy if else loops to find the installed software can I use an uninstall function in my script and pass the installed packages as variables.

Could anyone of you please suggest me how I can wrtie my function block and call it to unistall only specifc packages or please suggest me if there is better way to accomplish this task.

Anyhelp is greatly appreciated!
Old 11-01-2012, 12:19 AM   #2
Registered: Jan 2012
Location: South Africa
Posts: 501

Rep: Reputation: 189Reputation: 189
Hi there,

A few quick suggestions.

Firstly, I'd advise against using "lsllp -l | grep 'ABC'" just in case 'ABC' appears in a description rather than a fileset name somewhere. "lslpp -l '*ABC*'" avoids that.

Next you can get to the fileset names only by running:
lslpp -Lc '*ABC*' | awk 'BEGIN {FS=":"} !/^#/ {print $1}'
Lastly you can remove these one at a time with the help of xargs. Try this first to test that it produces the desired commands:
lslpp -Lc '*ABC*' | awk 'BEGIN {FS=":"} !/^#/ {print $1}' | xargs -n1 echo lslpp -u
If it works, just remove the "echo" and you're good to go.

Good luck!

Last edited by cliffordw; 11-01-2012 at 12:21 AM. Reason: fixed minor typos


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
cd command usage a in shell script using bash chuckt6 Linux - Newbie 5 04-21-2012 11:44 AM
[SOLVED] Problem With Shell Script Variable Usage Crowey Linux - General 2 02-09-2010 01:03 AM
shell script? : usage of $! with su -c option DTParanoia Linux - General 3 04-05-2005 05:58 PM
How do I uninstall packages in shell? Borg Swarm Linux - Newbie 1 01-22-2004 05:27 PM
Uninstall a shell script? (Crossover Office) Trinity22 Linux - Software 3 12-09-2003 02:37 PM > Forums > Other *NIX Forums > AIX

All times are GMT -5. The time now is 06:41 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration