好幾行stdout一次只處理一行內的數字 - Linux

By Ophelia
at 2016-04-05T10:05
at 2016-04-05T10:05
Table of Contents
我舉個例
fdisk -lu /dev/sda|grep ^/dev/sda
/dev/sda1 63 1646699 823318+ 83 Linux
/dev/sda2 1690000 5450000 1880000+ 83 Linux
/dev/sda3 5559999 11979999 3210000+ 83 Linux
/dev/sda4 11995000 2930275054 1459140027+ 5 Extended
/dev/sda5 11999999 17187199 2593600+ 83 Linux
像這樣,我雖然可以用cut分別切
cut -c 6-10
cut -c 16-25
cut -c 28-37
cut -c 39-49
得到一連串裝置名(文字)、起點、終點、長度,但是我想把這個送到其他指令
譬如dd或badblocks做處理,以行為單位
有點像是把置名(文字)、起點、終點、長度分別設成$A,$B,$C,$D這樣,
然後我再把這些變數丟到後續指令像是
/sbin/badblocks -sv /dev/sda -o /tmp/$A.bad $C $B
所以和其他行沒關係,一次只處理一行的資訊。
請問我該如何處理?
--
"Don't hate the player. Hate the game."
當看到哪個名人賺了大錢,領到高額補助或利息,不要去指責他,
而是要指責那個制度、創造那個制度的人,以及默許那個制度的人。
不然你認為一個人不領18%或是一個人不炒房價,就會改變整體環境嗎?
還不如改變【修改制度的人】,才能從根源改變一切。
--
fdisk -lu /dev/sda|grep ^/dev/sda
/dev/sda1 63 1646699 823318+ 83 Linux
/dev/sda2 1690000 5450000 1880000+ 83 Linux
/dev/sda3 5559999 11979999 3210000+ 83 Linux
/dev/sda4 11995000 2930275054 1459140027+ 5 Extended
/dev/sda5 11999999 17187199 2593600+ 83 Linux
像這樣,我雖然可以用cut分別切
cut -c 6-10
cut -c 16-25
cut -c 28-37
cut -c 39-49
得到一連串裝置名(文字)、起點、終點、長度,但是我想把這個送到其他指令
譬如dd或badblocks做處理,以行為單位
有點像是把置名(文字)、起點、終點、長度分別設成$A,$B,$C,$D這樣,
然後我再把這些變數丟到後續指令像是
/sbin/badblocks -sv /dev/sda -o /tmp/$A.bad $C $B
所以和其他行沒關係,一次只處理一行的資訊。
請問我該如何處理?
--
"Don't hate the player. Hate the game."
當看到哪個名人賺了大錢,領到高額補助或利息,不要去指責他,
而是要指責那個制度、創造那個制度的人,以及默許那個制度的人。
不然你認為一個人不領18%或是一個人不炒房價,就會改變整體環境嗎?
還不如改變【修改制度的人】,才能從根源改變一切。
--
Tags:
Linux
All Comments

By Agnes
at 2016-04-08T17:18
at 2016-04-08T17:18

By Charlie
at 2016-04-13T00:57
at 2016-04-13T00:57

By Emily
at 2016-04-17T03:53
at 2016-04-17T03:53

By Franklin
at 2016-04-21T07:37
at 2016-04-21T07:37

By Robert
at 2016-04-22T03:28
at 2016-04-22T03:28

By Carol
at 2016-04-23T18:43
at 2016-04-23T18:43

By Elma
at 2016-04-26T08:59
at 2016-04-26T08:59

By Isla
at 2016-04-26T17:31
at 2016-04-26T17:31

By Thomas
at 2016-04-27T05:45
at 2016-04-27T05:45
Related Posts
關於mac

By Frederica
at 2016-04-04T16:35
at 2016-04-04T16:35
字體別名無效

By Eden
at 2016-04-04T01:13
at 2016-04-04T01:13
文件內數字轉換的方法(分轉秒 時轉秒)

By Barb Cronin
at 2016-04-03T23:26
at 2016-04-03T23:26
GRUB2的關機指令

By Eden
at 2016-04-03T22:17
at 2016-04-03T22:17
安裝Linux 分割槽問題

By Leila
at 2016-04-03T21:20
at 2016-04-03T21:20