請問能在 loop 中使用已定義的變數嗎? - Linux

By Ida
at 2020-12-29T14:56
at 2020-12-29T14:56
Table of Contents
大家好
我將我的 code 簡化後如下:
A_var=/home/fileA.txt
B_var=/home/fileB.txt
for nn in A B
do
head $"${nn}_var"
done
希望能有
head /home/fileA.txt
head /home/fileB.txt
的效果
但我試了各種加上括號或引號的組合都沒有辦法,所以上來問問看,謝謝大家!
--
我將我的 code 簡化後如下:
A_var=/home/fileA.txt
B_var=/home/fileB.txt
for nn in A B
do
head $"${nn}_var"
done
希望能有
head /home/fileA.txt
head /home/fileB.txt
的效果
但我試了各種加上括號或引號的組合都沒有辦法,所以上來問問看,謝謝大家!
--
Tags:
Linux
All Comments

By Leila
at 2020-12-30T04:25
at 2020-12-30T04:25

By Zanna
at 2020-12-31T11:18
at 2020-12-31T11:18

By Erin
at 2021-01-05T10:36
at 2021-01-05T10:36

By Suhail Hany
at 2021-01-08T07:43
at 2021-01-08T07:43
Related Posts
可以問樹莓派的問題嗎?

By Robert
at 2020-12-28T18:45
at 2020-12-28T18:45
關於CentOS之死,請轉用Debian。

By Ingrid
at 2020-12-27T19:04
at 2020-12-27T19:04
crontab執行無效的問題

By Cara
at 2020-12-25T16:49
at 2020-12-25T16:49
語音軟體

By Sandy
at 2020-12-20T21:20
at 2020-12-20T21:20
Ubuntu新版的問題開機system bootOrder

By Jack
at 2020-12-20T20:35
at 2020-12-20T20:35