log.txt的格式:怎麼做我想從log.txt文件此字符串
;Index,Level,StripSize,SizeinMB,Status,Bootable,Array,Name
0,0,32kB,8192,"Normal","Yes",0,"FFS"
1,0,128kB,19046,"Normall","No",0,"Dev_Cache"
2,0,64kB,305244,"Normalll","Yes",1,"0W24SWKT"
或其他格式:
;Index,Level,StripSize,SizeinMB,Status,Bootable,Array,Name
0,0,32kB,8192,"Normal","Yes",0,"FFS"
1,0,128kB,19046,"Available","No",0,"Dev_Cache"
2,0,64kB,305244,"Normal","Yes",1,"0W24SWKT"
下面
是我的步驟:
iffs.sed
/Bootable/{
n;
s/^.*[0-9],\"([a-zA-Z]+)\",.*$/set abc=\1/p;
}
1. sed -nrf iffs.sed log.txt
result: set abc=Normal
2. sed "2d" log.txt |sed -nrf iffs.sed
result: set abc=Normal or Available
3. sed "2,3d" log.txt |sed -nrf iffs.sed
result: set abc=Normal
你能幫助簡單的方法嗎? windows os和winpe 3.0環境。 和我想要得到這樣的結果 「設置ABC2 =正常;設置ABC3 =正常或可用;設置abc4 =正常」
什麼字符串是你想獲得? – gfortune 2012-03-07 03:20:56
這個問題被標記爲Python,C,sed和AWK ?! – chrisaycock 2012-03-07 03:30:22
數據格式大喊「使用awk」是一件好事,否則我會問同樣的問題。現在我只能得到awk -F,'... {print'abc =「$ 5}; ...'log.txt – technosaurus 2012-03-07 03:31:36