問一個shell script的寫法 - Linux

Table of Contents


words=`cat test.dat`

for word in ${words};do
echo "word"
done


最後輸出再sort即可
這樣不知道可不可以?
※ 引述《Arim (Arim5566)》之銘言:
: 各位版友好
: 小弟想要請教一個寫法
: 假如我有一個檔案test.dat
: 內容為
: abstract continue for false new switch
: assert default if package synchronized
: boolean do goto private this
: break double implements protected throw
: byte else import public throws
: case enum instanceof return transient
: catch extends int short try
: true
: char final interface static void
: class finally long strictfp volatile
: const float native super while null
: 現在想要把他調整成每一行只有一個word,並且可以依照ASCII值做排列
: 例如
: abstract
: assert
: boolean
: ....
: ...
: 排列那個我知道可以用sort
: 只是一行一個word不知道要怎麼寫比較好@@
: 請問要怎麼寫比較好??
: 感謝各位版友

--

All Comments

Agatha avatarAgatha2011-02-23
這樣沒排序 XDDD
Lucy avatarLucy2011-02-24
done | sort 就好了啊XD
Kelly avatarKelly2011-02-28
他不是自己會排序了嗎XD
Ingrid avatarIngrid2011-03-05
加一下應該就好了~
Wallis avatarWallis2011-03-05
for loop會直接按 in xxx 中的順序
Delia avatarDelia2011-03-08
原來如此 我笨了 orz
Delia avatarDelia2011-03-13
我是說原po他說他會排序阿XD