Here’s a script that will help you count the lines of input from the standard input: result=0 while read inputline do result=`expr $result + 1` done echo $result Now, you can find out the number of files in a directory using: ls -1 | count Update As Jeff Harver has kindly pointed out in the…
Tag: shell
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. #!/bin/bash #Shell Script to backup desired target verbose=”0″ tarv=”” if test “$1” == “-v”; then verbose=”1″ tarv=”-v” fi if test “$verbose”…
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…
Access super user shell
I recently had a problem with my Debian box; namely, that I couldn’t access my superuser shell the usual way by typing: su – As this is a problem with the user bit of the “su” command not being set properly, you can fix this by logging in as root (or any other user with…
Setting up SSH keys
Here’s a short tutorial showing how to set up SSH authorized keys.
Using Linux Shell to Add a User
Adding a user with bash command is simple: “useradd username”