# SHELL Lab Activity Solution

### **Task1:**

```bash
#!/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:**

```bash
#!/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:**

```bash
#!/bin/bash

cal > o1.txt #1
date >> o1.txt #2

for (( i = 0; i < 100; i++ )); do #3
	echo "IIIT Hyderabad is cool" >> o1.txt
done

cat o1.txt #4
cat o1.txt | head -n 3 #5

sed -n 6,15p o1.txt #6

cat o1.txt | grep -o "IIIT Hyderabad is cool" | wc -l #7
echo "ISS Zindabad" > o2.txt #8
cat o2.txt | wc -w #9
echo "I am Kassi." >> o2.txt #10
cat o2.txt | wc -l #11
cat o1.txt | awk '{print $4}' #12
cat o1.txt | awk '{print $2 " " $3 " " $4 " " $5}' #13
cat o1.txt | awk '{print $3}' | head -n -5 #14
cat o1.txt | awk '{print $2 " " $4}' #15
```
