LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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
  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: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
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



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 On
HTML code is 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

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxQuestions.org Member Success Stories

All times are GMT -5. The time now is 01:23 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