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:

Update

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.