Remove grep's line number output in Redhat 5.9

I havent used RH 5.9 until now. I started with 6 but we have some 5.9 servers. The syntax with 5.9 is a bit different with some things. grep for example will output a number line before the actual search. Here is an example of that:

grep john /etc/shadow
38:john:!$1$/LW9cOmI$.QidFjJmq5xjKfmKugLAy0:16311:0:99999:7:::

38 is the line number there. In RH 6, this has been fixed. We are using grep (GNU grep) 2.5.1. Im not the sysadmin so updating grep is unlikely to happen. However, I'd like to know if there is a workaround. I am used to the grep in RH 6. This is a problem because when I do stuff like this, it is actually the wrong field:

cat /etc/shadow |grep john | awk -F: '{print $2}'
john

When in reality, field 2 should indicate the password field. Is there an option in grep to disable these number lines? I searched and havent found my answer yet. Thanks.

7

1 Answer

Check the GREP_OPTIONS environment variable.

Set it to nothing just in case then try again:

GREP_OPTIONS=''

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like