shell script 變數問題 - Linux

Erin avatar
By Erin
at 2014-01-22T20:03

Table of Contents

想請教一下為何下列第二和第三種方法會顯示錯誤訊息

1.
TMP1=/root/zh/pp/pg1.tmp
TMP2=/root/zh/pp/pg2.tmp

2.
q=1
while [ "$q" -le "4" ];do
TMP${q}=/root/zh/pp/pg${q}.tmp
q=`expr $q + 1`
done

3.
for q in 1 2 3 4
do
TMP$q=/root/zh/pp/pg$q.tmp
done

第二和第三錯誤訊息都是
+ TMP1=/root/zh/pp/pg.tmp
pp.sh: line 4: TMP1=/root/zh/pp/pg1.tmp: No such file or directory
+ TMP2=/root/zh/pp/pg2.tmp
pp.sh: line 4: TMP2=/root/zh/pp/pg2.tmp: No such file or directory

--
Tags: Linux

All Comments

Xanthe avatar
By Xanthe
at 2014-01-26T01:19
加個 env ?
Tom avatar
By Tom
at 2014-01-29T15:25
" "
Hedda avatar
By Hedda
at 2014-01-30T03:02
應該是補 eval, ex: eval TMP${q}=/root/zh/pp/pg${q}.tmp

lf95 not found

Annie avatar
By Annie
at 2014-01-22T13:17
我要安裝一個叫talys的軟體 README裡面寫到 https://www.dropbox.com/s/k04n9m5y61c3i75/README talys.setup https://www.dropbox.com/s/ardxgrm4w1q30am/talys.setup #compiler ...

fff script on LINUX/UNIX

Quintina avatar
By Quintina
at 2014-01-22T13:15
請問一下 我使用一個軟體要我 compile fff 2) compile the modified routines (with the fff script on LINUX/UNIX): fff yyy.f (produces a new file yyy.o) 但我執行後 發現沒這指令 leea ...

一個快速切換路徑的方法

Sandy avatar
By Sandy
at 2014-01-22T09:47
各位好, 之前看到學長用Ubuntu 假設原本在 /home/gg/data/fig1/rdcost $ 他只要 $ cd $myself 就馬上轉到 /home/gg/ns-allinone2.35/ns-2.35 $ 我只記得在什麼bash哪裡增加就可以 有人知道嗎? 抱歉,在這個版問這 ...

如何修改系統 /lib 路徑為其他路徑

Edwina avatar
By Edwina
at 2014-01-21T11:25
小弟作業系統 : ubuntu 12.04 程式在跑的時候預設會去 /lib 下找 library 請問這個路徑有可能更改嗎? 不是增加搜尋路徑 而是讓系統不要在 /lib 下找 library 因為 /lib 這個路徑我想做其他事 感恩 - ...

有無可回復前次關閉時所有分頁的編輯器?

Tracy avatar
By Tracy
at 2014-01-20T21:45
有點像 firefox/chrome 的重啟前次關閉時所有分頁的功能,只是需要的是文字 編輯器,不知道有沒有這種東西? 目前是用系統的 gedit,但有時系統更新完重開機後,要再逐一開啟先前編輯的檔 案,有點麻煩,甚至有時忘了開了哪些檔案,如果有這種功能的編輯器就會非常方便, 先感謝! - ...