I have this script that will show the user the head or tail of the files that are inside a set directory (currently that is set as '~/bin/new/*'). This script works but i would like to allow the user to not only show the head or the tail, but so that they can select the directory.
The current script is written as:
while true;do echo "Would you like to list the head or tail?" read headortail if [[ $headortail = head ]]; then head -n 4 ~/bin/new/* break elif [[ $headortail = tail ]]; then tail -n 4 ~/bin/new/* break else echo "Invalid Input - Please Input head or tail" fi done
If I add another line under the first echo such as:
echo "Please type the directory" read dirLocation
How could i implement this to the script, would I do:
head -n 4 $dirLocation
Would that work?