1
0

More than 1 year has passed since last update.

shellscriptの配列で管理している値を、pythonの標準入力に渡してリストで扱う

Posted at

shellscriptの配列で管理している値を、pythonの標準入力に渡してリストで扱う方法です
(ニッチかもですが)

shellscriptの配列

test.sh
arr=("100" "200" "300")
arr+=("400")
echo ${arr[@]}

pythonの標準入力に渡してリストで扱う

test.py
l = list(map(int, input().split()))
print(l)

実行(パイプで渡す)

$ bash test.sh
100 200 300 400
$ bash test.sh | python test.py
[100, 200, 300, 400]

これでOK(皆さんはどうやってるのでしょうか)

参考

【bash】シェルの配列について

1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0