I'm creating a script that prompts a user to enter a file name and search for the lines in the file, the longest line, and the shortest line. Here's what I have.
#!/bin/bash echo -n "Enter a filename:" read file if [ -e "$file" ] then wc -l $file; echo "lines" && wc -L $file; echo "longest" echo "$file exists" else echo "$file does not exist" fi
This is the content of the text file I am using for the test. Hopefully this will help.
~$ cat simple.txt I have too many things to do today. It's going to take to long to get everything done. My day is very busy. Why such a long face.
Please excuse my formatting and or structure. I am at the early stages of learning shell script and appreciate any help.