Scripting Practice
This lab is intended for you to practice writing a shell script
Write a shell script that does the following
- accepts two arguments ($1 and $2) which are file names
- On separate lines preceded by a title
- show the number of words in $1 and $2
- show the number of lines in $1 and $2
- show the number of characters in $1 and $2
Math in shell:
The expr command allows us to "do math" with symbols + - * /
This is a correct way to add 3 and 7 using expr:
x=`expr 3 + 7`
These are incorrect:
expr 3 + 7 -- Note this is how you do addition in the command prompt
`expr 3+7`
`expr 3 +7`
`expr 3+ 7`
Try to get this to work:
expr 3 * 3
Write a shell script that does the following
- accepts two arguments ($1 and $2 which are numbers)
- On separate lines preceded by a title
- show the sum of $1 and $2
- show the product of $1 and $2
- show the difference of $1 and $2