1

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
  • 3
    Are you sure it's not set up as an alias to grep -n which is the normal command to show line numbers? Type alias to see if it's listed. – garethTheRed Aug 29 '14 at 20:48
  • Try running \grep john /etc/shadow. It'll run command without any predefined arguments. If it works try looking at you aliases and remove -n flag from alias from grep. – nisargjhaveri Aug 29 '14 at 21:31
  • I have looked at the aliases and the \grep command and nothing good out of it yet – unixpipe Aug 29 '14 at 22:22
  • What's the output of alias? – ernie Aug 29 '14 at 22:24
  • 1
    Just the ls, ll, vi and which commands, no grep – unixpipe Aug 29 '14 at 22:29
2

Check the GREP_OPTIONS environment variable.

Set it to nothing just in case then try again:

GREP_OPTIONS=''

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.