Archive for the ‘Linux Quiz’ Category

Linux Quiz #008

Friday, June 15th, 2007

Bandwidth Monitor (Submit Answer)

Create a script in the language of your choice to monitor transmit and receive bandwidth in bytes per second. The script should accept two arguments, the interface to monitor and the interval it is checked (in seconds). Output should be in CSV format to STDOUT with the following fields: Timestamp,Interface,RX Bytes/sec,TX Bytes/sec.

Example output:

wriley@behemoth:~$ BWMon --interface eth0 --interval 2
Timestamp,Interface,RX Bytes/Sec,TX Bytes/Sec
2007-05-16 09:10:16,eth0,2043,0
2007-05-16 09:10:18,eth0,1963,0
2007-05-16 09:10:20,eth0,1518,0
2007-05-16 09:10:22,eth0,2304,0
2007-05-16 09:10:24,eth0,1326,0

Linux Quiz #007

Thursday, May 10th, 2007

Shell Word Count (Submit Answer)

Create a bash shell script that when given a filename as the first argument will print out the number of words in the filename. The filename can be any text file and a word is defined as a sequence of one or more printable characters, not including whitespace characters.

Linux Quiz #006

Tuesday, December 19th, 2006

Shell Calculator (Submit Answer)

This Linux Quiz once again calls for a shell script. Create a shell script that outputs the following when called with “–help” or “-h” as an argument:

Usage: mycalc OPERATOR FIRST SECONDWhere OPERATOR is one of add,subtract,multiply,divide
and
FIRST and SECOND are numeric

When the script is called with OPERATOR FIRST SECOND it should print the correct result. For example:

mycalc add 1 2

should print 3

mycalc divide 32 4

should print 8 and so on.

Extra Credit:
Design your script to accept parameterized arguments, such as –op=divide -f=1 -s=2, that can be entered in any order.

Linux Quiz #005

Monday, August 21st, 2006

A Brief History of Shell (Submit Answer)

With apologies to Dr. Hawking, let’s dive right in. This quiz is a short one. Assuming a bash shell, what does the following command
accomplish?

bash$ ls -l !275:^