From: Eric Bambach <eric@cisu.net>
To: Dog Walker <forestiero@qwest.net>
Cc: linux-newbie@vger.kernel.org
Subject: Re: Adding to the PATH but not if already in $PATH
Date: Sat, 26 Feb 2005 13:05:35 -0600 [thread overview]
Message-ID: <200502261305.35751.eric@cisu.net> (raw)
In-Reply-To: <200502261017.00466.forestiero@qwest.net>
On Saturday 26 February 2005 12:17 pm, you wrote:
> I want to prepend a directory to my PATH in my $HOME/.bashrc and export the
> result. But I only want it to happen once: iow, if a directory I want
> prepended is already in the PATH, do not prepend it again.
>
> Something like:
>
> if "/home/dw/bin" not in $PATH ; then
> PATH=/home/dw:$PATH
> export PATH
> fi
>
> The questions are: Is this the way one guards against multiple additions in
> subshells? Is there a way to check for a substring?
sed and grep can help.
echo $PATH | grep 'SOMEPATH'
if [ $? == 0 ];then
export PATH
else
PATH=NEWPATH
fi
Check the login on that though, shouldnt be too hard.
> -
> To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
--
----------------------------------------
--EB
> All is fine except that I can reliably "oops" it simply by trying to read
> from /proc/apm (e.g. cat /proc/apm).
> oops output and ksymoops-2.3.4 output is attached.
> Is there anything else I can contribute?
The latitude and longtitude of the bios writers current position, and
a ballistic missile.
--Alan Cox LKML-December 08,2000
----------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
next prev parent reply other threads:[~2005-02-26 19:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-26 18:17 Adding to the PATH but not if already in $PATH Dog Walker
2005-02-26 19:05 ` Eric Bambach [this message]
2005-02-26 19:40 ` DogWalker
2005-02-26 20:34 ` Eric Bambach
-- strict thread matches above, loose matches on Subject: below --
2005-02-26 18:16 Dog Walker
2005-02-26 22:44 ` chuck gelm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200502261305.35751.eric@cisu.net \
--to=eric@cisu.net \
--cc=forestiero@qwest.net \
--cc=linux-newbie@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox