Find the answer to your Linux question:
Results 1 to 2 of 2
I am trying to update '/etc/profile' to add an entry to $PATH. What I would like to do is insert the new path as the last entry in $PATH, but ...
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Posts
    5

    Need to insert text after a specific line of text.

    I am trying to update '/etc/profile' to add an entry to $PATH. What I would like to do is insert the new path as the last entry in $PATH, but only for root.

    This is the text I want to modify:

    Code:
    # Path manipulation
    if [ `id -u` = 0 ]; then
            pathmunge /sbin
            pathmunge /usr/sbin
            pathmunge /usr/local/sbin
    fi
    What I need is:

    Code:
    # Path manipulation
    if [ `id -u` = 0 ]; then
            pathmunge /sbin
            pathmunge /usr/sbin
            pathmunge /usr/local/sbin
            pathmunge /opt/myapplication/bin after
    fi
    I could simply append the following to the end of '/etc/profile', but I was hoping for a more elegant solution.

    Code:
    # Path manipulation
    if [ `id -u` = 0 ]; then
            pathmunge /opt/Navisphere/bin after
    fi
    Any help would be appreciated.

    Thanks.

  2. #2
    Just Joined! sathiya's Avatar
    Join Date
    Feb 2008
    Location
    Bangalore, India
    Posts
    97
    Code:
    # Path manipulation
    if [ `id -u` = 0 ]; then
    PATH=$PATH:/opt/myapplication/bin
    fi
    Hope the above helps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...