SHELL Lab Activity Solution

Task1:

#!/bin/bash

if [ "$#" -ne 3 ]; then
    echo "Correct number of arguments not provided" # Can print anything here
fi

echo "$1*$2*$3" | bc -l

Task2:

#!/bin/bash

grep -io "to" hamlet.txt #1
grep "\bis\b" hamlet.txt #2
grep -A 2 'bear' hamlet.txt #3
chmod 744 hamlet.txt #4
chmod 444 hamlet.txt #5
groups #6
ls -l | awk '{ if ($1 -eq "......x...") print $9}' #7

Task3:

Last updated

Was this helpful?