[問題]一些指令問題

看板Linux作者 (Anson)時間10年前 (2015/09/28 11:56), 編輯推噓1(108)
留言9則, 4人參與, 最新討論串1/1
小弟最近初學遇到一題不知道怎解 題目是這樣的 Student wants to display 1 to 1000 numbers with an expansion of 2.Meaning the output should be:1 3 5 7 9 11...Student dont know to write a script. Please help him with a single command to display this. Repeat the same to display all alphabets with expansion of 4 so as to display A E I M … 請大家指導一下 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 50.176.80.252 ※ 文章網址: https://www.ptt.cc/bbs/Linux/M.1443412574.A.A87.html

09/28 12:51, , 1F
man seq
09/28 12:51, 1F

09/28 14:17, , 2F
bash -c "echo {1..1000..2}"
09/28 14:17, 2F

09/28 14:17, , 3F
bash -c "echo {A..Z..4}"
09/28 14:17, 3F

09/28 16:33, , 4F
bash 沒有 {1..100..2} 這類語法吧,ksh 才支援
09/28 16:33, 4F

09/28 16:41, , 5F
不過剛剛看了一下,bash 4.x 有支援沒錯
09/28 16:41, 5F

09/28 16:41, , 6F
我被手上跑的 bash 3.x linux server 騙了:~
09/28 16:41, 6F

09/28 16:47, , 7F
還在用bash3不怕shellshock?
09/28 16:47, 7F

09/28 16:49, , 8F
不過的確bash4加了很多features
09/28 16:49, 8F

09/28 17:03, , 9F
centos5的bash還是bash3.2啊 不過有打過patch了XD
09/28 17:03, 9F
文章代碼(AID): #1M2BfUg7 (Linux)
文章代碼(AID): #1M2BfUg7 (Linux)