Sample Header Ad - 728x90

Head and tail of files in a directory, selected by the user

0 votes
1 answer
337 views
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?
Asked by S.Jones (81 rep)
Dec 9, 2015, 06:02 PM
Last activity: Aug 30, 2023, 10:39 AM