Thank you Write the output and function for following shell


Thank you
Write the output (and function) for following shell script and C statement. $pwd /Home $ls HW3.pdf ql.sh $cat q1. Ah if ( -e /HW3.pdf ) then echo The full path of HW3.pdf is \'pwd\' else echo Triple Dot HW3 does not exist in current directory. f1 $./q1.sh Output: $cat q2 . sh #| /bin/sh ros = 0 x = 0 # check command line if [$# -lt 2] ; then echo \"oops! I need at least 2 command line args\" echo \"syntax: $0: number 1 number 2 Triple Dot number N\" echo \"Example : $0 56 66 34\" exit 1 fi for i, in $0 do x = \'expr $x + 5i\' done res = \'expr $x / $#\' echo \"res = $res\" $./q2.sh 3 Output: Continue on question 2) $. /q2.sh 12 4 8 Output: function: Note: use low bar to represent a space. print f (\"%6d, %4d\", 25, 1234); Output: print f (\"%.4f\", 3.1415926); Output: print f(\"%8.5e\", 20.253); Output: print f (\"% - 8.5f\", 20.253); Output:

Solution

1)$pwd
/Home
$ls
HW3.pdf q1,sh
$cat q1.sh
if [ -e /HW3.pdf ]
then
echo the full path of HW3.pdf is \'pwd\'
else
echo HW3 does not exist in current directory.
fi
$./q1.sh

Output: HW3 does not exist in current directory.

2) $cat q2.sh
#!/bin/sh
res=0
x=0
check command line
if [ $ -lt 2 ] ; then
echo \"Oops! I need atleast 2 command line args\"
echo \"Syntax: $0: number1 number2 ... numberN\"
echo \"Example:$0 56 66 34\"
exit 1
fi
for i in $0
do x= \'expr $x + $i \'
done
res=\'expr $x / $4 \'
echo \"res = $res\"
$.q2.sh 3

Output: res= expr $x / $4

4) a) printf(\"%6d,%4d\", 25, 1234);

Output: 25,1234

b) printf(\"%.4f\", 3.1415926);

   Output: 3.1416

c) printf(\"%8.5e\", 20.253);

  Output: 2.02530e+01

d) printf(\"%-8.5f\", 20.253);

  Output:  20.25300

 Thank you Write the output (and function) for following shell script and C statement. $pwd /Home $ls HW3.pdf ql.sh $cat q1. Ah if ( -e /HW3.pdf ) then echo The
 Thank you Write the output (and function) for following shell script and C statement. $pwd /Home $ls HW3.pdf ql.sh $cat q1. Ah if ( -e /HW3.pdf ) then echo The

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site