我有一个小的python程序,该程序分析一个文本文件并将输出写入另一个文件.目前,我正在编写一个bash脚本来多次调用该程序,看起来像:
I have a small python program that parses a text file and writes the output to another file. Currently, I am writing a bash script to call this program several times, it looks something like:
for i in $(seq 1 100); do python /home/Documents/myProgram.py myTextFile$i done这很好,但是我想知道bash脚本文件中是否可以包含python程序,因此当另一个用户运行该脚本时,他们不需要在内存中包含python程序;也就是说,是否可以将python程序复制并粘贴到bash脚本中,然后在脚本本身中运行它?
This works fine but I want to know if it is possible to have the python program inside the bash script file so when another user runs the script they don't need to have the python program in their memory; i.e., is it possible to copy and paste the python program into the bash script and run it from within the script itself?
推荐答案#!/bin/bash python - 1 2 3 << 'EOF' import sys print 'Argument List:', str(sys.argv) EOF
输出:
Argument List: ['-', '1', '2', '3']更多推荐
如何在bash脚本中插入python程序?
发布评论