msgbartop
A chronological documentation test project, nothing serious, really!
msgbarbottom

01 Feb 2008 Align output from commands using column

The column command is a little shell command that makes it easy to print the results in a aligned fashion.

Example 1

/dev/mapper/vg0-root  on  /              type  ext3    (rw,errors=remount-ro)
tmpfs                 on  /lib/init/rw   type  tmpfs   (rw,nosuid,mode=0755)
proc                  on  /proc          type  proc    (rw,noexec,nosuid,nodev)
sysfs                 on  /sys           type  sysfs   (rw,noexec,nosuid,nodev)
procbususb            on  /proc/bus/usb  type  usbfs   (rw)
udev                  on  /dev           type  tmpfs   (rw,mode=0755)
tmpfs                 on  /dev/shm       type  tmpfs   (rw,nosuid,nodev)
devpts                on  /dev/pts       type  devpts  (rw,noexec,nosuid,gid=5,mode=620)
/dev/mapper/vg0-home  on  /home          type  ext3    (rw)
/dev/mapper/vg0-tmp   on  /tmp           type  ext3    (rw,nosuid)
/dev/mapper/vg0-var   on  /var           type  ext3    (rw)

Example 2

cat /etc/passwd | column -t -s ":"

or

column -t -s ":" /etc/passwd

Result example 2

lp           x   7      7      lp                                  /var/spool/lpd         /bin/sh
mail         x   8      8      mail                                /var/mail              /bin/sh
news         x   9      9      news                                /var/spool/news        /bin/sh
uucp         x   10     10     uucp                                /var/spool/uucp        /bin/sh
proxy        x   13     13     proxy                               /bin                   /bin/sh
www-data     x   33     33     www-data                            /var/www               /bin/sh
backup       x   34     34     backup                              /var/backups           /bin/sh
list         x   38     38     Mailing List Manager                /var/list              /bin/sh
irc          x   39     39     ircd                                /var/run/ircd          /bin/sh
gnats        x   41     41     Gnats Bug-Reporting System (admin)  /var/lib/gnats         /bin/sh
nobody       x   65534  65534  nobody                              /nonexistent           /bin/sh

The column command supports the following options

-c      Output is formatted for a display columns wide.

-n      By default, the column command will merge multiple adjacent delimiters into a single delimiter when using
         the -t option; this option disables that behavior.

-s      Specify a set of characters to be used to delimit columns for the -t option.

-t      Determine the number of columns the input contains and create a table.  Columns are delimited with whites‐
         pace, by default, or with the characters supplied using the -s option.  Useful for pretty-printing dis‐
         plays.

-x      Fill columns before filling rows.

Tags: ,

Posted by

28 Oct 2007 Updating WordPress using a bash script

If you have shell access to your webserver this script can be used to upgrade your WordPress installation to the latest version quickly. Always remeber to backup your database and installation files before running it!

Do change the bold text to reflect your WordPress Internet address before you run the script.

#!/bin/bash
CURDIR=$(pwd)
SITE="http://yoursite.com/wordpress"
echo Updating WordPress located in $CURDIR
echo 1. Downloading latest WordPress install file.
wget -q http://wordpress.org/latest.tar.gz
echo 2.  Unpacking downloaded file.
tar zxf latest.tar.gz
cd wordpress/
echo 3.  Replacing old files with the unpacked ones.
tar cf - . | (cd $CURDIR; tar xf -)
echo 4.  Update the WordPress installation.
wget -q -O - ${SITE}/wp-admin/upgrade.php?step=1> /dev/null
echo 5.  Removing the WordPress file downloaded recently.
rm -f ../latest.tar.gz
echo 6.  WordPress is now upgraded.

Tags: , , ,

Posted by