How to use env command to change GREP_OPTIONS variable?

How could I use the env command to change the enviroment variable GREP_OPTIONS so that grep is not case sensitive by setting it to "-i'?

So that the command:

grep a <<< A

Will produce the same output as

grep -i a <<< A

Any attempts/ideas/thoughts from your side? What would man env say?

1 Like

Would

env $GREP_OPTIONS="-i"

work?

*EDIT:*
Actually I got

env GREP_OPTIONS=-i grep a <<< A

to work.

env GREP_OPTIONS=-i grep a <<< A
A

What happened when you tried it on your server? I would expect a syntax error from env $GREP_OPTIONS="-i"

Try:-

GREP_OPTIONS="-i"            # Assign the value to the variable
grep a <<< A                 # Test it

Does that help?

Robin

1 Like

Looks like he sneak-edited after your question.

I'm so sneaky with my large *EDIT:* tag.

Note that your "large *EDIT:* tag", is exactly the same size as the rest of the text in your post (so I'm not sure what "large" means in this case). :confused:

Note also that anyone subscribed to your thread will receive notification by e-mail when a new post is added to your thread after the current contents have been read; but will receive no notice when you edit a post. And, if someone trying to help you is editing a response to one of your posts, there isn't much incentive to go back and look for changes in posts that have already been read -- unless you add a new post pointing out that earlier text has been modified. :mad:

Those of us who read a lot of threads in this forum and try to help out by answering questions appreciate it when new information is added by submitting a new post to the thread instead of by editing an existing post. :rolleyes:

My apologies, by large I meant and should have written "capitalized".

Thank you for your suggestion I will now post replies instead of edits. I just wanted to add to what I had been trying as a solution in the same post for context but I supposed as you pointed out that a reply is preferred to an edit and I see that it would make more sense to post a reply.

I'm still relatively new to Unix and thus this site so I do not know the generally preferred way to reply so thank you for the feedback.

2 Likes

Hi steezuschrist96,
With only 10 posts, we certainly don't expect you to be an expert; and every forum has its own idiosyncrasies. No apology was necessary. I just wanted to make a couple of suggestions that will help you get the most out of your activities here.

Cheers,
Don

2 Likes