If you need to remove all repositories, use this command:
zypper repos | grep Yes | cut -f3 -d '|' | sed -e "s/ //" | awk '{print "zypper rr " $1}' | bash
I would suggest first to try to see the output of the command without the last bash:
zypper repos | grep Yes | cut -f3 -d '|' | sed -e "s/ //" | awk '{print "zypper rr " $1}'
This was helpful, thanks. Not sure why there isn't a zypper option to do this already.
ReplyDeleteSure, I am glad it was useful for you
DeleteThis comment has been removed by the author.
ReplyDeleteIn SLES 15, the addon repositories you select during installation will be automatically added to the OS repository list. I wanted to remove these repositories all at once, but looks like the Aliases contain spaces. So this neat command fails. I was unable to put quotes around the awk output. So here is what I came up with:
ReplyDeletefor i in $(seq $(($(zypper lr | wc -l)-4))); do zypper rr 1; done
This is my take on this, a variation of the above: Delete the first entry in the repo list as long as there are entries in this list. Using the XML out + filter for the closing tag of a single repository () as indicator for the existence of a repo:
ReplyDeletewhile $(zypper -x lr | grep -q '</repo>'); do zypper rr 1; done
for repofile in $(ls -1 /etc/zypp/repos.d/); do zypper rr $(basename ${repofile} .repo); done
ReplyDelete