shell script裡讀檔並取出值 - Linux

George avatar
By George
at 2013-07-08T13:47

Table of Contents

大家好!想請問以下狀況該如何做:

我有一個文字檔(例如叫a.dat),裡面有如下之資訊:

1000 1 2 3 4 5
2000 2 3 4 5 1
3000 1 3 4 2 5
..............

現在希望讀a.dat後,把第二到六個位置的值,依序寫到我的for loop裡,例如:

for a in 1 2 3 4 5
do
//job
done

但在下一個loop,變成

for a in 2 3 4 5 1
do
//job
done

這樣依序做下去

請問,該如何讀檔,並把我要的值給到一個二元矩陣?

感謝幫忙:)

--
Tags: Linux

All Comments

Callum avatar
By Callum
at 2013-07-08T22:39
bash: read -a
Hedda avatar
By Hedda
at 2013-07-13T04:41
http://pastebin.com/xeEWF2aH
Elizabeth avatar
By Elizabeth
at 2013-07-15T00:30
非常感謝以上兩位,尤其imcar :)

Cent OS 6.4無法進入歡迎設定頁面

Delia avatar
By Delia
at 2013-07-06T00:35
小弟的機器是Supermicro的電腦 已安裝兩顆硬碟設定做RAID 1 早上因練習RAID卡如何設定,重新安裝Linux兩三次都沒問題 剛剛晚上因朋友想練習,不知道是否動到甚麼東西,重新安裝Linux後都一直無法進入 歡迎的設定頁面!! 畫面在長條型藍白色跑馬燈,跑完之後畫面就變黑了,無法出現歡迎 ...

Fedora16 許多問題

Bennie avatar
By Bennie
at 2013-07-05T20:17
各位大大好,由於要比賽小弟被規定使用Fedora16版本 小弟已有Debian6.0.7的一些小經驗 可是在Fedora16還是深受打擊..... Q1.我要開啟Apache需要先進入 /etc/httpd/conf.d/perl.conf 把LoadModule perl_module module ...

如何在ubuntu上知道java執行狀況

Kumar avatar
By Kumar
at 2013-07-05T17:37
事情是這樣的 剛剛我用ssh遠端連到虛擬機器(ubuntu 12.04,只有文字介面) 然後執行 java的jar檔 當下有回傳 程式的執行印出的字串 後來我關閉ssh 重新連到那台虛擬機器 我要怎麼繼續看 剛剛的程式執行到哪了(讓它繼續印字串,並回傳給我) 請版上的大大幫忙小弟一下 小弟 ...

急求救- Debian EXT3消失症...?

Wallis avatar
By Wallis
at 2013-07-05T12:47
訊息1 ============================== exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0 exception BMPMA state 0x4 exception cmd c8/00:08:00:60:39/00: ...

請問yum 的fastestmirror plugin

Kelly avatar
By Kelly
at 2013-07-05T00:18
請問一下 我的機器上 有Centos原來的repo,但我連不到 另外有個自已的repo A,連得到 而我用yum install 時,都會顯示 fastestmirror plugin 選擇Centos repo,然後連不上 請問為何呢? 而現在我不方便disable 或移掉centos repo f ...