How can I create a shell script in unix/linux to find the number of lines in a text file that have words which are 5 to 10 character long and begin with a capital letter?
Assuming the original question meant to count the number of lines matching the above requirements, then this should do it:
Assuming it meant to print the line numbers that match:
The way the question is now, it means, filter out lines, starting with a capital letter (like this line) [the line has to start with a capital letter - not the word], and include a word (not necessarily the first word) which is 5 to 10 characters long.
Yes, after reading the original question, there are 4 possibilities to interpret it: The Starting word has to fulfill both requirements or it is a starting word and another word, and: Get the line numbers, or the number of lines.
To print the line numbers for lines, which begin with a capital letter, and contain a word somewhere of length 5-10, we use sed:
|show 1 more comment|