Linux

Remove duplicate packages when querying the rpm database

Today I had to solve a RPM problem on a Red Hat Enterprise Linux WS release 4 (Nahant Update 6) system (RHEL4) where there were duplicate packages when querying the rpm database. This had happened after an upgrade to update 6 using up2date from the command line. It seemed like i386 and x64 packages had […]

Read More
Linux

Create a year calendar for 2008 using pcal

I wanted to make a whole year calendar and found pcal, a command line tool. pcal -F 1 -E -B -O -p -w -o 2008.ps 2008 -F starting weekday; 1 is Monday -E specifies European formatted dates -B leave unused date boxes blank, default is grey -O selected days will be printed as outlined characters […]

Read More
Linux

Backup mysql databases into separate files

This bach script makes separate backup files of all the databases in mysql and saves the result in the mysql_backup folder. #!/bin/bash -v USERNAME=’yourusername’ PASSWORD=’yourpassword’ HOSTNAME=’yourhostname’ BackupFolder=’/backup’ for i in $(echo ‘SHOW DATABASES;’ | mysql –user $USERNAME -p$PASSWORD -h $HOSTNAME | grep -v ‘^Database$’ ); do mysqldump –user $USERNAME -p$PASSWORD -h $HOSTNAME –opt $i > […]

Read More
Network

Sort IP address

Sorting IP addresses using sort is not easy because the dot confuses sort. This line makes it possible to sort by the whole value of the address sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 ipaddresses.txt You can also sort by the last octet sort -r. -n +3.0 ipaddresses.txt

Read More