2017/08/14

bashのリストも大抵はpythonのように書ける

a correspondence table between bash's and python's list indexing.

以下、対応
それぞれの意味とかは自分で調べよう。

python -- bash

pylist[:] <--> ${balist[@]}
pylist[:4] <--> ${balist[@]::4}
pylist[-6:] <--> ${balist[@]: -6} #(マイナス記号があるときは ':' の後にスペース必須 | white space after colon)
pylist[-12:-4] <--> ${balist[@]: -12:8} #(-4-(-12)=8)
pylist[1:9:2] <--> none??


0 件のコメント: