Suppose I have the following text file called inputFile
:
hello
HELLO
Hello World
wOrld
asdgfsafd
abc 123
1 3 5 a b
and I want to print out the lines containing only one word(any sequence with uppercase/lower case letters), regardless if there are spaces before or after the character, using egrep and regex.
so the output should look like this:
hello
HELLO
wOrld
asdgfsafd
The best regex I came up was
egrep ' *[a-zA-Z] *$' inputFile
but it does't seem to work. Any suggestions?