我是双向的。
我已经在Batch和Powerhell发表《白奴》。 我想把它 in成黑白。
在bash,如果是某类信托,产出:
BootCurrent: 0003
Timeout: 2 seconds
BootOrder: 0011,0000,0001,0013,0014,0015,0004,0003,0016,0017
Boot0000* ThrottleStop UEFI
Boot0001* rEFInd Boot Manager
Boot0003* MX23 LinuX
Boot0004* Windows Boot Manager
etc...
我尝试:
#!/bin/bash
cd /home/mrkey7/Desktop/
sudo efibootmgr > file.txt
echo "$(grep "Boot00" file.txt)"
echo [R] Reboot
echo [S] Shutdown
echo [E] Exit
read -n 1 -p "Choose:" ans;
case $ans in
r|R)
sudo reboot;;
s|S)
sudo poweroff;;
*)
exit;;
esac
产出:
Boot0000* ThrottleStop UEFI
Boot0001* rEFInd Boot Manager
Boot0003* MX23 LinuX
Boot0004* Windows Boot Manager
[R] Reboot
[S] Shutdown
[E] Exit
Choose:
我希望产出如下:
[1] ThrottleStop UEFI
[2] rEFInd Boot Manager
[3] MX23 LinuX
[4] Windows Boot Manager
[R] Reboot
[S] Shutdown
[E] Exit
Choose:
然后,一只新闻“1”,就将boot到“ThrottleStop UEFI”。 供“rEFInd Boot”经理使用的“2”间。 等等。
页: 1 法典:
#!/bin/bash
sudo efibootmgr | awk /^Boot[0-9]/{ gsub(/[Bot*0]/, "", $1)
Index = ++ $1; sub(/^S+ /, "", $0)
printf("[% 2u] %s
", Index, $0); }
echo [R] Reboot
echo [S] Shutdown
echo [E] Exit
read -n 1 -p "Choose:" ans;
case $ans in
r|R)
sudo reboot;;
s|S)
sudo poweroff;;
*)
exit;;
esac
the 产出:
[ 1] ThrottleStop UEFI
[ 2] rEFInd Boot Manager
[ 4] MX23 LinuX
[ 5] Windows Boot Manager
[ 2] Setup
[12] Boot Menu
[13] Diagnostic Splash
[14] USB FDD:
[15] ATA HDD: ADATA SU650
[16] USB HDD:
[17] USB CD:
[18] PCI LAN:
[R] Reboot
[S] Shutdown
[E] Exit
Choose:
new problem, new ask (maybe my first question wrong). I don t want number greater than 9. So, i want to replace the output number with Alphabet sequance ABCDE like this:
[A] ThrottleStop UEFI
[B] rEFInd Boot Manager
[C] MX23 LinuX
[D] Windows Boot Manager
[E] Setup
etc...
[1] Reboot
[2] Shutdown
[3] Exit
Choose: