Posts Categorized: shell

Coloring Bash Output

Colour bash shell script output

I wanted to add some colour to the output of my bash shell script and was able to do so with the following – very simple red and green:

Bash Shell Script to Automate FTP File Transfer

A little script to send a backup file to a remote FTP server:

Then run it every day from Cron.

Adaptec Hardware RAID controller on Sun 4150

On our Oracle Sun x4150’s the Hardware Raid can be checked after installing the StorMan software which is available (as StorMan-6.40.x86_64.rpm)  in the software bundle for x4150s available after logging in to the Oralce support website and locating the downloads for x4150s. The download is pretty big (931MB) when the 39MB RPM is all you are… Read more »

Using Sed to convert Mac Address

I have output from a router (but I believe modem output may be similar) with mac addresses in the format: 0050.56AC.4022 Four digit blocks separated by dots but I needed it in the format of 2 digit blocks separated by colons. My router output was lines like this: INTERNET  123.111.123.111   8      0050.56AC.1765  ARPA  VLAN.1.16… Read more »

Web Screenshots with Xvfb and Khtml2Png2

To get that headless Linux server capturing screenshots of web pages we need: Xvfb e.g. apt-get install xvfb Khtml2png2 (and dependencies) After installation of the above the steps are below and I wrapped it up into a PHP script which also did some database tasks to keep records of the screenshots. 1.Check if the Xvfb… Read more »

Remove Line Breaks with tr

I had a text file with multiple lines of input that I was manipulating using awk and sed but I found the following ‘tr’ command easiest to remove the line breaks: cat input.txt | tr -d ‘\n’

Zero Filling a Disk in Linux

The simple way to wipe or zerofill a disk is: dd if=/dev/zero of=/dev/sd? bs=1M However I found an article describing how to zero-fill with a progress indicator using pipebench, installed on Debian/Ubuntu with: sudo apt-get install pipebench then use: tr ‘\000’ ‘\377’ < /dev/zero | pipebench | sudo dd of=/dev/sd? Substitute the question mark for… Read more »

Bash: Looping through Files with Spaces

I was trying to move some miscellaneous music files into directories by artist name. The files (and folders) have spaces in the file names. For my first attempt I tries a for loop e.g. for file in $(find /path/to/music -type f); do … done A for loop will not do this regardless of how much… Read more »

echo with new lines

For future reference: echo “This does not give \n a new line” does not work. I had used printf sometimes but the -e switch also works for echo: echo -e “This gives \n a new line”