删除内核的perl脚本
来源:
作者:
时间:2008-12-02
Tag:
点击:
有时候ub用久了,升级多了,内核也更新了一大堆,搞的选择菜单一大堆东西,实在是看不过眼,加上浪费空间,还是删除了好,简洁。不过手动删比较麻烦(本人觉得,呵呵)所以写个脚本,呵呵!
code:
|
#!/usr/bin/perl -w
use strict; die "Permission denied:Perhaps need root\n" if `whoami`!~/root/; my @all_image=split("\n",`dpkg --get-selections | grep 'linux-' | grep -v 'deinstall'`); my @old_image; foreach(@all_image) {
if($_=~s[(linux-image-\d\.\d\.\d{2}-\d{2}-generic).*][$1]i)
{
push(@old_image,$_);
}
}
my $i;
my $choose;
while(1)
{
$i=0;
foreach(@old_image)
{
print ++$i,'.',$_,"\n";
}
print "please choose image which you want to delete:(0 for quit)";
chomp($choose=<STDIN>);
if($choose==0)
{
exit(0);
}
elsif($choose>@old_image)
{
print "\nERROR:Unavailable Selection\n";
next;
}
last;
} `apt-get remove $old_image[--$choose]`||die "\n";
|
相关文章: