这是声明
sudo update-alternatives --install "/usr/bin/word" "word"
"/usr/lib/jvm/jdk1.8.0_version/bin/word" 1
其中需要用这些名称逐一替换单词:
appletviewer jarsigner jconsole jrunscript native2ascii schemagen xjc
apt java jcontrol jsadebugd orbd javac jdb jstack pack200 servertool
extcheck javadoc jhat jstat policytool tnameserv
HtmlConverter javah jinfo jstatd rmic unpack200
idlj javap jmap jvisualvm rmid wsgen
jar javaws jps keytool rmiregistry wsimport
例如我们的输出应该是这样的:
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/bin/java 1
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/bin/jar
答案1
像这样的东西应该能够逐行逐字地读取你的文件:
while read line; do
for word in $line; do
sudo update-alternatives --install /usr/bin/$word $word /usr/lib/jvm/bin/$word
done
done < filelist