LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories
User Name
Password
LinuxQuestions.org Member Success Stories Just spent four hours configuring your favorite program? Just figured out a Linux problem that has been stumping you for months?
Post your Linux Success Stories here.

Notices

Reply
 
LinkBack Search this Thread
Old 02-26-2005, 10:37 PM   #1
lfur
Member
 
Registered: Jul 2003
Location: Slovenia
Distribution: Slackware & FreeBSD
Posts: 209

Rep: Reputation: 30
set path problem solved


Hi!

Actually this is not a question but rather an answer to my own questions/problems, which I think is worth posting here (thanx to acid_kewpie and Dark_Helmet for suggestions on this topic posted previously).
So here it goes:

this is a (bash) function for checking your path entries for duplicates and that evil dot (.)

Code:
function setpath() {
  newpath=""

  for old in $(echo $1 | sed -e "s/:/\n/g" | grep -v "\.")
  do
    if [ -d "$old" ]
    then
      bad=0
      for new in $(echo $newpath | sed -e "s/:/\n/g")
      do
        if [ "$old" == "$new" ]
        then
          bad=1
        fi
      done
      if [ "$bad" == "0" ]
      then
        if [ "$newpath" == "" ]
        then
          newpath=$old
        else
          newpath=${newpath}:$old
        fi
      fi
    fi
  done
 }
... it takes only 1 argument which is a path to test.
To test your $MANPATH you should put:

Code:
setpath "$MANPATH"
export MANPATH=$newpath
after the function ... setting the path to check before it is required

Hope this helps anyone - it sure has served me good.

Enjoy,

Luka

Last edited by lfur; 02-26-2005 at 11:29 PM.
 
Old 02-27-2005, 05:08 PM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Lubuntu
Posts: 19,165
Blog Entries: 4

Rep: Reputation: 426Reputation: 426Reputation: 426Reputation: 426Reputation: 426
Moved: This thread is more suitable in Success Stories and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Set the path systemwide/Set the path for a user with Slackware jayhel Slackware 1 06-12-2005 12:24 AM
how to set path? here a meet the problem with ns2 installation cain_eve Linux - Newbie 12 12-16-2004 05:09 PM
'PEAR.php' (include_path=''.:/usr/local/lib/php'') SOLVED SOLVED adengua Linux - Software 0 04-02-2004 03:34 AM
How to set PATH How do I set PATH environment variable? Tranquil Linux - Newbie 3 11-02-2003 02:52 AM
$PATH!? how to set these PATH(s)!? sirpelidor Red Hat 5 10-25-2003 04:00 PM


All times are GMT -5. The time now is 05:12 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration