You are on page 1of 2

LAB2 ----SECOND BATCH------24th January 2012 1.

Write a shell script to remove all executable files from a directory, when a directory is given as argument. 2. Generate frequency list of all the commands you have used, and show the top 5 commands along with their count 3. Write a bash script that takes 2 or more arguments, i)All arguments are filenames ii)If fewer than two arguments are given, print an error message iii)If the files do not exist, print error message iv)Otherwise concatenate files 4. Write a shell script 'swap.sh' which takes two file names as command line arguments, and checks if the files exist in the current directory. If the files exist, the shell script has to swap the contents of the files, and displays the files' contents. 5. How to write shell script that will add two nos, which are supplied as command line argument, and if this two nos are not given show error and its usage 6. Write Script to find out biggest number from given three nos. Nos are supplies as command line argument. Print error if sufficient arguments are not supplied. 7. Write script to print nos as 5,4,3,2,1 using while loop. 8. Write Script, using case statement to perform basic math operation as follows + addition - subtraction * multiplication / division The name of script must be 'q4' which works as follows $ ./q4 20 / 3, Also check for sufficient command line arguments 9. A shell script is a text file containing shell commands. It must start with a line like #!/bin/bash, which names the shell interpreter to use. Write a shell script, guess.sh that implements a simple number guessing game. When run, the shell scriptprompts the user to guess a random number between 0 and 100. If the user guesses incorrectly, the script prompts the user Guess higher or Guess lower as appropriate and allows the user to guess again. If the user guesses correctly,the script terminates printing out how many guesses the user needed. For example: nitt$ ./guess.sh Guess my secret number (0-100): 101 Thats not between 0 and 100 Guess my secret number (0-100): 80 Guess higher Guess my secret number (0-100): 85 Guess lower

Guess my secret number (0-100): 82 Right! You guessed my secret in 3 guesses.

You might also like