I want to write a script that lists either the first n lines or the last n lines of a specified file.
cd $1=filename $2=string $3=lenght if [ "$filename" == "head" ] #If the user uses the head command then do the following. then [ "$filename" == "tail" ] head -n 10 /MyDirectoryGoesHere else #If the user uses the tail command do this instead. tail -n 10 /MyDirectoryGoesHere fi
When I run this command I keep getting an error "Unexpected token near else" and I was told to add a for loop but don't know how or where. Appreciate the help.