#!/bin/bash

# CS160B:  Viviane Marani
# Lab1

# Question 1
# create a symbolic link to xwindows.faq
printf "\nQuestion 1\n"
ln -s /pub/cs/grwoo/cs160b/Lab1/xwindows.faq ~/cs160b/Lab1/xwindows.faq
echo "-------------------"


# Question 2
# Output lines in xwindows that have at least two digits
printf "\nQuestion 2\n"
grep "[[:digit:]][[:digit:]]" xwindows.faq
echo "-------------------"


# Question 3
printf "\nQuestion 3\n"
# First Option
grep "^[[:alpha:] ][[:alpha:] ]*$" xwindows.faq 
echo "-------------------"
# Second Option
grep -ve '[[:digit:]]' -e '[[:punct:]]' -e '^$' xwindows.faq
echo "-------------------"


# Question 4
printf  "\nQuestion 4\n"
# All the lines containg only 3 digits, followed by  one or more of . - or space, followed by 4 digits"
# Examples" 345.3456 or 123-1234 or 234 2345 or 345..3456 or 123--456 or 567  6789
grep -E '^[[:digit:]]{3}[-. ]?[[:digit:]]{4}$' xwindows.faq
echo "-------------------"


# Question 5
# Substitutes X-Window to X Window and outputs to std out
printf "\nQuestion 5\n"
cat xwindows.faq | sed "s/X-Window/X Window/g" 
echo "-------------------"