Processing XML on the Command Line

The other day on the cURL email list, someone asked:
Could someone please tell me (preferably with an example) of how I could parse and xml like the following:

< ?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>

This is not appropriate for the cURL list, but I …

Removing duplicate RPMS.

Got the script mainly with google search on the link.

Nice trick..

Get the list of rpms with just the names
rpm -qa –queryformat \’%{name}\\n\’ > pkglist

Get the non-uniques list.
sort -g pkglist | uniq -d > duplicates

Get the versions of the duplicate files:
for pkg in `cat duplicates`; do
rpm -q $pkg >> removelist

Now keep the rpms that you want to delete in the removelist

and a simple command to remove them will be :
for pkg in `cat removelist`; do
rpm -e $pkg

vi – the powerful Linux/Unix text editor

We will talk about some vi stuff today:

Some fun first-->
2) help 42

Ok, coming to serious things-
3) Linux cheat sheet:

Commands and tips:
6) Something that is difficult to find on the net is : how to create a numbered list in vi/vim? Simple, we will use macro\'s
To do this:
a> type number and terminatory ex: 1)
b> start recording using <ALT>qa  . This will record the macro in a.
c> yank the line with yy
d> goto next line
e> press <CTRL>a to increment the number
f> End the macro recording with q
g> Play the macro with numner of times to repeat the actions. Example press 11@a
7) For repeating the last command you can use <dot>
8) You can put your vim settings in ~/<dot>vimrc and this can containg things like \"set nu\" and any other configuration.
9) Adding date in vi : <ESC>:r! date
10) There is a variant of vi known as elvis which is quite nice
11) Similarly for viewing binary file there is a variant called bvi