寫script自動化的過程,常會遇到要如何去頭去尾。
這裡可以使用以下指令:
sed -i '$ d' detsys.txt && sed '1d' detsys.txt說明: detsys.txt 是檔案名稱
去首行是:
sed -i '$ d' detsys.txt
去尾行是:
sed '1d' detsys.txt
當然也可以直接從SMCIPMITool著手,使用found list可以把抓到的IPMI裝置儲存成一個檔案。
例如執行前,執行後的圖樣:
sed -i '$ d' detsys.txt && sed '1d' detsys.txt說明: detsys.txt 是檔案名稱
sed -i '$ d' detsys.txt
sed '1d' detsys.txt
intel_iommu=on iommu=pt
ifconfig
cat /sys/class/net/ethx/address
cat /etc/udev/rules.d/70-persistent-net.rules
ip link show
cat dhcpd.leases | egrep 'lease|hardware ethernet' | sed -e '1,2d' -e 's/lease/\ /g' -e 's/hardware/\ /g' -e 's/ethernet/\ /g' -e 's/ //g' -e 's/\x3B/\x00/g' -e 's/\x7B/\x00/g'
The application encountered an error while attempting to change the state of "xxx" (VM_Name). The virtual machine could not be started because the hypervisor is not running.