Here is a small bash script to test a hard drive transfer speed. It should be take as an approximation. The speed value is taken from Linux dd command output. One way to test your hard drive speed is to use hdparm command:

This is a simple skeleton of a bash countdown script. The script takes two arguments . Here are some examples of its usage:

  • countdown time to 90 minutes from now:
./bash-countdown.sh -m 90
  • countdown time to 23.3.2036 from now:
./bash-countdown.sh -d "Mar 23 2036"
  • countdown time to 21:06 from now:
./bash-countdown.sh -d 21:06
  • countdown time to 21:06:45 from now:
./bash-countdown.sh -d 21:06:45

This simple perl script will print your external IP address assigned by you internet provider ( great for someone with dynamic IP address ).

First, we download a html file from ipchicken.com and then phrase this file to match for IP address in format X.X.X.X using regular expression.

Next, the script removes all unnecessary characters and prints your external IP address on the terminal. Lastly, the script removes previously downloaded index.html file.

The following bash script allows user to check for domain name availability using a whois utility ( Domain hijacking made easy ). User needs to only supply single or multiple keywords and the script checks domain availability for each keyword+domain-label. See below for a sample output.

Please feel free to add more generic domain labels into the list. However, test your whois server on what it returns if domain is available as not all whois servers return the exact string. I have tested only domains which are currently in the bash script below. When you get a string which your whois server returns when domain name is available, add it to the script's grep line starting with prefix"|". The chances are that if you add new domain name label the script will just work, but if not you know what to do.

Insert following lines into a file called check-domain-availability.sh

Here are two ways on who to redirect both standard output and standard error to same file in bash. First the official a recommended way:

printf '%s\n%\n' "Hello bash" > FILE 2>&1

now easier unofficial way:

Sometimes it is needed to check what user is executing the bash script and whether the user supplied all required arguments:

This Perl programming tutorial is a great scripting guide to help you fully understand Perl script. Find Perl tutorials and programming examples to master your knowledge of Perl Scripting.

Hello World Bash Shell Script

Attention: For more verbose and beginner style Bash scripting tutorial visit our Bash Scripting Tutorial for Beginners

First you need to find out where is your bash interpreter located. Enter the following into your command line:

$ which bash

This article provides few simple scripts to scan and monitor network using combination of bash and ping command. Obviously, these scripts are no match to a full monitoring dedicated software like nagios but they could be useful for a small home brand networks, where implementing sophisticated monitoring system can become an overhead.

Scan network subnet

In this example the bash script will scan network for hosts attached to an IP address 10.1.1.1 - 255. The script will print message Node with IP: IP-address is up if ping command was successful. Feel free to modify the script to scan your hosts range.

When writing a bash scripts most of us by default use echo command as means to print to standard output stream. echo is easy to use and mostly it fits our needs without any problem. However, with simplicity very often comes limitation. This is also the case with echo command. Formatting an echo command output can be a nightmare and very often impossible task to do.

The solution to this can be a good old friend of all C/C++ the “printf” tool. printf can be just as easily implemented into a bash script is it is used with C/C++ programs. This article describes some basics of printf along with practical examples:

FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: