LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-12-2014, 06:39 PM   #1
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Rep: Reputation: Disabled
Warning from grep


I use several aliases that use grep, for example:
Code:
alias lsgp="ls /var/log/packages | grep $1"
Since the recent update of grep, I have been getting this output from my alias:
Code:
$ lsgp zsh
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
zsh-5.0.2-x86_64-1
I have crawled through the man page & cannot decipher what I need to do to my alias to eliminate the warning. Some pointers, please.
Regards,
Bill
 
Old 12-12-2014, 07:10 PM   #2
mancha
Member
 
Registered: Aug 2012
Posts: 484

Rep: Reputation: Disabled
Hi.

Seems you're setting GREP_OPTIONS somewhere (.bashrc/.bash_profile/.zshrc, etc.) and grep is letting you know it is deprecating this.

You can check with:

Code:
$ export | grep GREP
You can replace the environment variable and add the options directly to your alias to accomplish the same thing. For example, to have
grep show the matched strings in color you can do something like:

Code:
$ alias lsgp="ls /var/log/packages | grep --color=auto $1"
If you don't want to remove GREP_OPTIONS, for whatever reason, you could instead suppress the warning with an alias like:

Code:
$ alias lsgp="ls /var/log/packages | grep $1 2>/dev/null"
--mancha

Last edited by mancha; 12-12-2014 at 07:28 PM. Reason: add 2nd option
 
1 members found this post helpful.
Old 12-13-2014, 07:53 PM   #3
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Original Poster
Rep: Reputation: Disabled
Thanks, mancha. With your tip, I found I was setting the GREP-OPTIONS in my bashrc. I was able to modify my aliases to get the same results & eliminate the GREP-OPTIONS line.
Regards,
Bill
 
Old 11-09-2015, 01:32 PM   #4
smitchel1099
LQ Newbie
 
Registered: Dec 2007
Posts: 15

Rep: Reputation: 0
put the cookies on the bottom shelf!

When I run the suggested command:
Code:
export | grep GREP
I indeed get 1 result:
Code:
declare -x GREP_OPTIONS="--color"
And when use the command:
unset GREP_OPTIONS
and run the first command again, there are no results.

The missing step for me is how to find out where the "declare -x" statement is originating from.

How do you find what is setting the GREP_OPTIONS env. variable in the first place?
 
Old 11-09-2015, 03:50 PM   #5
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Original Poster
Rep: Reputation: Disabled
In my case, I think GREP_OPTIONS was being set in /etc/profile.d/coreutils-dircolors.sh. I modified my alias to the first form listed by mancha & it works perfectly. For other ls aliases, I used the LS_OPTIONS env. var., as in:
Quote:
alias ls='/bin/ls $LS_OPTIONS'
GREP_OPTIONS may be set in any of the scripts in /etc/profile.d/ or in any bash startup script.
Regards,
Bill
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find & grep - how to return pathes, not grep phrases ? postcd Linux - General 2 11-25-2014 12:43 PM
grep to file outputs more than grep to screen? tcpman Linux - Server 4 06-07-2013 04:46 AM
Creating an alias in ksh that uses grep and includes 'grep -v grep' doug248 Linux - Newbie 2 08-05-2012 02:07 PM
Trying to understand pipes - Can't pipe output from tail -f to grep then grep again lostjohnny Linux - Newbie 15 03-12-2009 10:31 PM
ps -ef|grep -v root|grep apache<<result maelstrombob Linux - Newbie 1 09-24-2003 11:38 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration