I think you just need to add the "beginning of a line" character to only grep the lines that have no spaces before them.

grep '^package com.att.com;' file

Works in Solaris.

Your wording is a little confusing... normally when grep is used as a verb, at least in my experience, it means "get the lines that include". So if I want to find the lines in a dcoument that has the word foo them, I say "I want to grep for foo"

So... do you want to grep for the lines w/ spaces before the words or only those without spaces before the words?

Do include in the output the lines w/ spaces before, use the first example provided by Jim. If you want to exclude the lines w/ spaces before the text from your output, use the one I provided.

# one space in front of it anywhere on the line
grep ' package com.att.com;' file
# one or more white spaces
grep '[ \t]*package com.att.com;' file
# at the beginning of the line
grep '^ package com.att.com;' file
# one or more spaces at the beginning
grep '^[ \t]*package com.att.com;' file
# one or more spaces where it is at the end of the line
grep '[ \t]*package com.att.com;$' file

You need to be ultra-specific in asking for what you want.

The Following User Says Thank You to jim mcnamara For This Useful Post: