[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Which one to use - $@ "$@" $*
From: |
Christopher Dimech |
Subject: |
Re: Which one to use - $@ "$@" $* |
Date: |
Fri, 23 Apr 2021 18:17:02 +0200 |
Looks like you just want to re-pass the arguments to another program (e.g. to
grep in your case). In such instance, the procedure is to use "$@"
> Sent: Saturday, April 24, 2021 at 4:09 AM
> From: pauline-galea@gmx.com
> To: "help bash" <help-bash@gnu.org>
> Subject: Which one to use - $@ "$@" $*
>
> Have written a grep function to which I can pass arguments.
> Am am using "$@". Reading about this, I found people claiming
> that $@ should be quoted, others say it is not required.
>
> Furthermore, there is $* which does not need quoting.
> I need help to resolve this because it is still not
> clear to me which one to use - $@ "$@" $*
>
> Here are same examples of how I use it.
>
> mygrep -C8 "Great Britain" ./gungadin
> mygrep -nhC8 "Great Britain" .
> mygrep -C8 --exclude=\*.texi --include=\*.el France .
> mygrep -C8 --exclude=\*.{org,texi} --include=\*.el France .
>
> mygrep ()
> {
> grep -ir --include=\*.{org,texi} "$@"
> }
>
>
>
>
>