To create an alias for grep and to exclude svn directory

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












To create an alias for grep and to exclude svn directory (currently no questions cover this) on bash env I did:



$ function gp grep -rnIi --exclude-dir='.svn';


However,
I get error



bash: syntax error near unexpected token `}'


How do I go about this?










share|improve this question























  • Kusalananda showed you how to define a gp function, but he didn’t explicitly identify the error in your attempt, which is that  










up vote
0
down vote

favorite












To create an alias for grep and to exclude svn directory (currently no questions cover this) on bash env I did:



$ function gp grep -rnIi --exclude-dir='.svn';


However,
I get error



bash: syntax error near unexpected token `'


How do I go about this?










share|improve this question























  • Kusalananda showed you how to define a gp function, but he didn’t explicitly identify the error in your attempt, which is that must be followed by a space (or a newline).
    – Scott
    Sep 10 at 21:04










  • Thanks Scott and Kusalananda. I changed my code to and it works: function gp() grep -rnIi --exclude-dir='.svn' $1 $2;
    – piyush89
    Sep 11 at 17:17














share|improve this question















To create an alias for grep and to exclude svn directory (currently no questions cover this) on bash env I did:



$ function gp grep -rnIi --exclude-dir='.svn';


However,
I get error



bash: syntax error near unexpected token `}'


How do I go about this?







bash alias bashrc subversion






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 10 at 20:35









RalfFriedl

4,1251625




4,1251625










asked Sep 10 at 19:48









piyush89

1




1











  • Kusalananda showed you how to define a gp function, but he didn’t explicitly identify the error in your attempt, which is that { must be followed by a space (or a newline).
    – Scott
    Sep 10 at 21:04










  • Thanks Scott and Kusalananda. I changed my code to and it works: function gp() grep -rnIi --exclude-dir='.svn' $1 $2;
    – piyush89
    Sep 11 at 17:17

















  • Kusalananda showed you how to define a gp function, but he didn’t explicitly identify the error in your attempt, which is that { must be followed by a space (or a newline).
    – Scott
    Sep 10 at 21:04










  • Thanks Scott and Kusalananda. I changed my code to and it works: function gp() grep -rnIi --exclude-dir='.svn' $1 $2;
    – piyush89
    Sep 11 at 17:17
















Kusalananda showed you how to define a gp function, but he didn’t explicitly identify the error in your attempt, which is that { must be followed by a space (or a newline).
– Scott
Sep 10 at 21:04




Kusalananda showed you how to define a gp function, but he didn’t explicitly identify the error in your attempt, which is that { must be followed by a space (or a newline).
– Scott
Sep 10 at 21:04












Thanks Scott and Kusalananda. I changed my code to and it works: function gp() grep -rnIi --exclude-dir='.svn' $1 $2;
– piyush89
Sep 11 at 17:17





Thanks Scott and Kusalananda. I changed my code to and it works: function gp() grep -rnIi --exclude-dir='.svn' $1 $2;
– piyush89
Sep 11 at 17:17











2 Answers
2






active

oldest

votes

















up vote
0
down vote













function is not alias



alias gp="grep -rnIi --exclude-dir='.svn'"





share|improve this answer
















  • 1




    As a function: gp () grep ... "$@";
    – Kusalananda
    Sep 10 at 20:02

















up vote
-1
down vote













I changed my code to:



function gp() grep -rnIi --exclude-dir='.svn' $1 $2;


and it works






share|improve this answer






















  • It’s better to use "$@", as Kusalananda suggested. It automatically expands to all the arguments that are passed to the function (i.e., $1 $2 $3 $4 …), so you can run it on many files / directories at once, and it quotes them, so your pattern and filenames can have spaces and special characters.
    – Scott
    Sep 11 at 20:07










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468098%2fto-create-an-alias-for-grep-and-to-exclude-svn-directory%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













function is not alias



alias gp="grep -rnIi --exclude-dir='.svn'"





share|improve this answer
















  • 1




    As a function: gp () grep ... "$@";
    – Kusalananda
    Sep 10 at 20:02














up vote
0
down vote













function is not alias



alias gp="grep -rnIi --exclude-dir='.svn'"





share|improve this answer
















  • 1




    As a function: gp () grep ... "$@";
    – Kusalananda
    Sep 10 at 20:02












up vote
0
down vote










up vote
0
down vote









function is not alias



alias gp="grep -rnIi --exclude-dir='.svn'"





share|improve this answer












function is not alias



alias gp="grep -rnIi --exclude-dir='.svn'"






share|improve this answer












share|improve this answer



share|improve this answer










answered Sep 10 at 19:51









Ipor Sircer

9,3481920




9,3481920







  • 1




    As a function: gp () grep ... "$@";
    – Kusalananda
    Sep 10 at 20:02












  • 1




    As a function: gp () grep ... "$@";
    – Kusalananda
    Sep 10 at 20:02







1




1




As a function: gp () grep ... "$@";
– Kusalananda
Sep 10 at 20:02




As a function: gp () grep ... "$@";
– Kusalananda
Sep 10 at 20:02












up vote
-1
down vote













I changed my code to:



function gp() grep -rnIi --exclude-dir='.svn' $1 $2;


and it works






share|improve this answer






















  • It’s better to use "$@", as Kusalananda suggested. It automatically expands to all the arguments that are passed to the function (i.e., $1 $2 $3 $4 …), so you can run it on many files / directories at once, and it quotes them, so your pattern and filenames can have spaces and special characters.
    – Scott
    Sep 11 at 20:07














up vote
-1
down vote













I changed my code to:



function gp() grep -rnIi --exclude-dir='.svn' $1 $2;


and it works






share|improve this answer






















  • It’s better to use "$@", as Kusalananda suggested. It automatically expands to all the arguments that are passed to the function (i.e., $1 $2 $3 $4 …), so you can run it on many files / directories at once, and it quotes them, so your pattern and filenames can have spaces and special characters.
    – Scott
    Sep 11 at 20:07












up vote
-1
down vote










up vote
-1
down vote









I changed my code to:



function gp() grep -rnIi --exclude-dir='.svn' $1 $2;


and it works






share|improve this answer














I changed my code to:



function gp() grep -rnIi --exclude-dir='.svn' $1 $2;


and it works







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 11 at 20:07









Scott

6,35642450




6,35642450










answered Sep 11 at 17:19









piyush89

1




1











  • It’s better to use "$@", as Kusalananda suggested. It automatically expands to all the arguments that are passed to the function (i.e., $1 $2 $3 $4 …), so you can run it on many files / directories at once, and it quotes them, so your pattern and filenames can have spaces and special characters.
    – Scott
    Sep 11 at 20:07
















  • It’s better to use "$@", as Kusalananda suggested. It automatically expands to all the arguments that are passed to the function (i.e., $1 $2 $3 $4 …), so you can run it on many files / directories at once, and it quotes them, so your pattern and filenames can have spaces and special characters.
    – Scott
    Sep 11 at 20:07















It’s better to use "$@", as Kusalananda suggested. It automatically expands to all the arguments that are passed to the function (i.e., $1 $2 $3 $4 …), so you can run it on many files / directories at once, and it quotes them, so your pattern and filenames can have spaces and special characters.
– Scott
Sep 11 at 20:07




It’s better to use "$@", as Kusalananda suggested. It automatically expands to all the arguments that are passed to the function (i.e., $1 $2 $3 $4 …), so you can run it on many files / directories at once, and it quotes them, so your pattern and filenames can have spaces and special characters.
– Scott
Sep 11 at 20:07

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f468098%2fto-create-an-alias-for-grep-and-to-exclude-svn-directory%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay