combine python function with for loops in bash terminal

Maulik Upadhyay

I aimed to open multiple files (one by one, using for loop in bash terminal) and modify it using PLINK (a programme) and later on, python function. Following are the codes:

for i in {1..10}; do
  plink --cow --noweb --lfile $i --extract extract1.snp --recode --out 1$i
  python -c 'import file_convert;file_convert.convert_tree_mix("1$i.map","tmp$i")'
done

But, as expected, python could not read and could not open "11.map", it did not replace "$i" with 1. How can i modify the code so that python function, in combination with for loop, open different file each time based on the value of "i"

Avinash Raj

You need to include the whole python code inside double quotes, so that the $1 inside the python code will expand. $1 in shell refers to the first parameter.

python -c "import file_convert;file_convert.convert_tree_mix(\"1$i.map\",\"tmp$i\")"

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to combine two loops

分類Dev

apply function repeatedly in python without loops

分類Dev

Bash For-loops with Floats

分類Dev

Combine single and multi argument variables in a function call for Python

分類Dev

Combine two foreach loops for better inefficiency?

分類Dev

python: Small Logical Error in a terminal function graphing class

分類Dev

Combine a function and for loop

分類Dev

Refactoring For-Loops in Python

分類Dev

Maya/Python - function which loops though text file except for some lines

分類Dev

Recursive function without loops or variables

分類Dev

Commands Working In Terminal, But Not In Bash Script

分類Dev

New Terminal bash file error

分類Dev

Bash Cat file to terminal centre

分類Dev

Command works in terminal but not in bash script

分類Dev

How to combine the dictionaries in python

分類Dev

combine two strings in python

分類Dev

Combine Multiple Lists (Python)

分類Dev

How to combine lapply with dplyr in a function

分類Dev

How to Condense Nested Loops in Python

分類Dev

How can I Combine or paste text in a linux command in terminal?

分類Dev

Why combine commands on a single line in a Bash script?

分類Dev

Combine sed commands into one command in bash script

分類Dev

How to combine a prefix to output of ls in bash?

分類Dev

Bash: Combine creating a file and storing the Path in a variable

分類Dev

Running Python File in Terminal

分類Dev

Print rectangle in python terminal

分類Dev

How to complete for loops inside of a recursive function?

分類Dev

what is the complexity/BIG O of this function "loops"

分類Dev

Running a command in a new terminal instance in a bash script

Related 関連記事

ホットタグ

アーカイブ