Count Lines From Standard Input in Shell

Here’s a script that will help you count the lines of input from the standard input:

Now, you can find out the number of files in a directory using:


As Jeff Harver has kindly pointed out in the comments, the same thing as the long script above can be accomplished using:

Backup Your Linux Machine

I was up to maintenance of my Debian box, and I came in need of creating and maintaining multiple, date-based backups of the machine.

Here is the bash script I wrote to accomplish this.

Once executed, this script will backup the target specified by “$target” (the whole filesystem in this case) and create a tar.gz file under “/backups/month/date.tar.gz”. You have to specify an “admin” email account to which notifications will be sent.

Having Your Shell Tweet

Have you ever wanted to have your *nix shell access Twitter?

Using the RESTful API, you can achieve this. However, you would need to set up your instance as an app and then configure the API keys and all the what-nots. I personally try to avoid such hassle whenever possible.

So, I got this shell script for you (which is not originally mine, but has undergone a fair bit of modification by me) which achieves this:

What this script does is fairly simple:

It opens up a a connection the mobile version of the twitter, submits a fake Login form, gains access to the page, and then posts all the input parameters collectively as your Tweet.

The problem currently is that you have to write in your twitter credentials inside the file. I might change that one day.


You will need to install “curl” on your machine to be able to run this.