开发者

Perl-oneliner to bash

开发者 https://www.devze.com 2023-01-08 21:52 出处:网络
perl -E \'$i=@{[`zypper lr`]}-2;map{`zypper rr $_`}1..$i\' What would be a good way to wr开发者_如何学JAVAite this perl-onliner in bash. ( I would like to remove all repositores with zypper)?Here\'s
perl -E '$i=@{[`zypper lr`]}-2;map{`zypper rr $_`}1..$i'

What would be a good way to wr开发者_如何学JAVAite this perl-onliner in bash. ( I would like to remove all repositores with zypper)?


Here's a way to do this:

The first command counts the number of lines produced by zypper lr command.

So, you obtain that by:

COUNT_LINES=`zypper lr|tail +3|wc -l`

The second command merely runs zypper rr [NUMBER] for each number 1 through the counter; so you run the for loop in bash as shown in this SO question:

How do I iterate over a range of numbers in bash?


zypper lr | grep -P "^\d" | cut -d'|' -f 1 | xargs sudo zypper rr

But much easier to simply:

sudo rm -rf /etc/zypp/repos.d/*
0

精彩评论

暂无评论...
验证码 换一张
取 消