2

How can I show all active package repos with zypper?

I need the output for a check script.

I know how to list them all. But I would like to avoid to parse this output with a regex:

foo-work:~ # LANG=C zypper lr
# | Alias                             | Name                          | Enabled | Refresh
--+-----------------------------------+-----------------------------------+---------+--------
1 | openSUSE 12.3 FOO-BAR           | openSUSE 12.3 FOO-BAR           | Yes     | Yes    
2 | openSUSE 12.3 FOO-BAR Test      | openSUSE 12.3 FOO-BAR Test      | Yes     | No     
3 | openSUSE-12.3 Updates (FOO-BAR) | openSUSE-12.3 Updates (FOO-BAR) | Yes     | Yes    
4 | openSUSE-12.3-Non-Oss (FOO-BAR) | openSUSE-12.3-Non-Oss (FOO-BAR) | Yes     | No     
5 | openSUSE-12.3-Oss (FOO-BAR)     | openSUSE-12.3-Oss (FOO-BAR)     | Yes     | No     
guettli
  • 3,811

2 Answers2

4

Are you looking for the -E, --show-enabled-only flag to only show enabled repositories, or the -e - , --export - to get the listing in the repository definition format that allows for much easier parsing?

zypper lr -E -e - |grep name=
HBruijn
  • 84,206
  • 24
  • 145
  • 224
0

This will print only the enabled repositories on SuSE:

zypper lr | awk -F'|' '{gsub(/ /, "", $0); if($4=="Yes") print $2}'

The gsub call is only there to remove the leading and trailing blanks.

duise
  • 1