#!/bin/bash
open1=`sudo yum list installed | grep jdk | awk 'NR==1{printf $1}'`
open2=`sudo yum list installed | grep jdk | awk 'NR==2{printf $1}'`
echo "--------------------"
echo $open1
echo $open2
echo "--------------------"
sudo yum remove $open1 $open2
shell 删除open jdk
终端输入
sudo yum list installed | grep jdk
后可以看到,机器默认安装的是open jdk
java-1.8.0-openjdk.x86_64 1:1.8.0.101-3.b13.el7_2 @updates
java-1.8.0-openjdk-headless.x86_64 1:1.8.0.101-3.b13.el7_2 @updates
sudo yum remove java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-headless.x86_64
最上面的shell既是取到这两个名包赋值给卸载命令