The wikis are now using the new authentication system.
If you did not migrate your account yet, visit

User:Tsu2/BASH zypper

Jump to: navigation, search

Repository Add and Initial Setup

Adding a repo

The following adds the LEAP 42.1 Perl repo, non-interactively automatically accepting defaults (Yes to all questions) and sets the repo to auto-refresh

zypper -n ar -f LEAP_42.1:Perl

Auto accept GPG keys

The following refreshes all repos, and automatically accepts the GPG keys for all newly added repos

zypper --gpg-auto-import-keys ref

Detect OS version and auto insert into add repo URI automatically

The following automatically detects the running openSUSE version, and installs the Perl repo example for that distro. The following does not support Tumbleweed.

VERSION=$(grep VERSION /etc/SuSE-release | sed -e 's/VERSION = //') && \
zypper ar -nf$VERSION/ openSUSE_$VERSIONIn:Perl

Tumbleweed vs all other stable openSUSE

The following can detect Tumbleweed vs all other current stable openSUSE. In the following example, if Tumbleweed is detected "net-tools-deprecated" is installed if a network setup requires consistent network interface naming across all openSUSE versions.


ID=$(grep -w ID= /etc/os-release | sed -e 's/ID=//')
VERSION_ID=$(grep -w VERSION_ID= /etc/os-release | sed -e 's/VERSION_ID=//' | sed -e 's/"//g')

if [ "$ID" = '"opensuse-tumbleweed"' ]; then

echo Tumbleweed detected, do TW stuff
zypper in net-tools-deprecated
# zypper -n ar -f openSUSE_Factory:science
# zypper --gpg-auto-import-keys ref

if [ "$ID" = '"opensuse-leap"' ]; then

echo This must be LEAP $VERSION_ID
echo Do LEAP stuff
# zypper -n ar -f$VERSION_ID/ openSUSE_$VERSION_ID:science
# zypper --gpg-auto-import-keys ref

Regular Expressions

A very important thing to know, how to handle Regular Expressions properly.
Includes a section and explanation about using quotes to avoid unintended Expansions

Regular Expressions


An important, powerful and versatile tool... It will search for any character or sequence in your text and replace...replace with a "nothing" and you've removed it! A really cool list of examples can be found at