Find the answer to your Linux question:
Results 1 to 4 of 4
i am trying to enable/disable repositories with a script. with sed i've been able to find a repo: Code: sed '/*'"$REPO"'/,/src/ s/^[ #]*//' /etc/apt/sources.list however, like this it also enables ...
  1. #1
    Just Joined! Leppie's Avatar
    Join Date
    Feb 2010
    Posts
    72

    [SOLVED] Edit sources.list from script

    i am trying to enable/disable repositories with a script.
    with sed i've been able to find a repo:
    Code:
    sed '/*'"$REPO"'/,/src/ s/^[ #]*//' /etc/apt/sources.list
    however, like this it also enables the src repo (even though "src" is set as the stop).
    how can i enable a repo (e.g. remove the comment for that repo) without enabling the source repo as well at the same time?

    all help much apreicated

  2. #2
    tpl
    tpl is offline
    Linux User
    Join Date
    Jan 2007
    Location
    cleveland
    Posts
    452
    did you try without the range pattern?
    i.e. omit the ",/src/"
    the sun is new every day (heraclitus)

  3. #3
    Just Joined! Leppie's Avatar
    Join Date
    Feb 2010
    Posts
    72
    Quote Originally Posted by tpl View Post
    did you try without the range pattern?
    i.e. omit the ",/src/"
    yeah, both with and without the "stop" parameter it enables both the normal and the source repo... this really got me puzzled, especially since i'm no sed/awk expert.

  4. #4
    Just Joined! Leppie's Avatar
    Join Date
    Feb 2010
    Posts
    72
    i solved this in a "hackish" way, concatenating the search term and omitting the search range:
    Code:
    sed "/#.*$REPO.*$SRCH/ s/^[ #]*//" /etc/apt/sources.list

Posting Permissions

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