自動在 for 迴圈中新增變量,而無需在每一行中新增變量

自動在 for 迴圈中新增變量,而無需在每一行中新增變量

有沒有辦法自動將 $i 變數加入到指令的開頭,而不必每次都指定它?

這是我目前的腳本。

#!/bin/bash

for i in "command -c"; do

$i command1 show

$i command2 show

done

我想要的是這樣的東西。

#!/bin/bash

for i in "command -c"; do
$i
(
command1 show

command2 show
)
done

相關內容