Question: ort script which uses a pipe to the wc program so that the variable num.files is set to the number of files in a directory,
ort script which uses a pipe to the wc program so that the variable num.files is set to the number of files in a directory, where the directory is given by the user as an argument to the script, and then echos that number when you run it. ) You can do simple addition and subtraction inside a Bash script with, for example, echo S[1+1]. Try it on the command line to see that it works. You can do multiplication and division as well, but only if the answer is an integer. If there is a decimal part in the answer it will be dropped. Try echo $[3/4] and see what you get. In order to do floating point arithmetic you need to download a program called bc (binary calculator). Use apt-get to install the program and then use it in a pipeline like echo 3/4 | bc -1. An example script would be #1 /bin/bash a-$(echo "scale-5 ; echo $a 5/3" | bc -1) You can read the man page for bc and try various inputs and other things to see how it performs. Write a script that calculates(x)sin(e) on the user supplied variable r and prints the result to the screen
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
