1. Verify different UNIX commands (syntax to use with options). 2. Write a shell program to add two numbers using command line. 3. Write a shell program to convert distance into me... 1. Verify different UNIX commands (syntax to use with options). 2. Write a shell program to add two numbers using command line. 3. Write a shell program to convert distance into meter, cm, and km. 4. Write a shell script to extract the data from the date command.

Question image

Understand the Problem

The question consists of multiple assignments related to UNIX commands and shell scripting. It requires verifying various UNIX commands, writing a shell program to add two numbers, converting distances, and extracting data from the date command.

Answer

1. Use 'man [command]' for help. 2. Add numbers: `sum=$(($1 + $2))`. 3. Convert distance: `$((cm/100000)) km`. 4. Date format: `date '+%A %B %d %T %Z %Y'`.
  1. Use 'man [command]' or '[command] --help' for UNIX command options.

  2. Shell program to add numbers:

#!/bin/bash
sum=$(($1 + $2))
echo "Sum is: $sum"
  1. Convert distance:
#!/bin/bash
read -p 'Enter distance in cm: ' cm
echo "$((cm/100000)) km $(((cm%100000)/100)) mt $((cm%100)) cm"
  1. Extract date:
date '+%A %B %d %T %Z %Y'
Answer for screen readers
  1. Use 'man [command]' or '[command] --help' for UNIX command options.

  2. Shell program to add numbers:

#!/bin/bash
sum=$(($1 + $2))
echo "Sum is: $sum"
  1. Convert distance:
#!/bin/bash
read -p 'Enter distance in cm: ' cm
echo "$((cm/100000)) km $(((cm%100000)/100)) mt $((cm%100)) cm"
  1. Extract date:
date '+%A %B %d %T %Z %Y'

More Information

These shell scripts demonstrate basic arithmetic, command line arguments, and formatting outputs based on command input.

Tips

Ensure numbers are passed correctly as arguments when running shell scripts. Remember variable expansion syntax.

AI-generated content may contain errors. Please verify critical information

Thank you for voting!
Use Quizgecko on...
Browser
Browser