loops

Iterate over arguments in a bash script and make use of their numbers

白昼怎懂夜的黑 提交于 2020-08-27 11:38:03
问题 If I want to iterate over all arguments it is as easy as for i in "$@"; do ... . However, let's say I want to start with the second argument and also make use of the arguments' positions for some basic calculation. As an example I want to shorten these commands into one loop: grep -v 'foobar' "$2" | grep -f $file > output1.txt grep -v 'foobar' "$3" | grep -f $file > output2.txt grep -v 'foobar' "$4" | grep -f $file > output3.txt grep -v 'foobar' "$5" | grep -f $file > output4.txt I tried many

Iterate over arguments in a bash script and make use of their numbers

狂风中的少年 提交于 2020-08-27 11:37:48
问题 If I want to iterate over all arguments it is as easy as for i in "$@"; do ... . However, let's say I want to start with the second argument and also make use of the arguments' positions for some basic calculation. As an example I want to shorten these commands into one loop: grep -v 'foobar' "$2" | grep -f $file > output1.txt grep -v 'foobar' "$3" | grep -f $file > output2.txt grep -v 'foobar' "$4" | grep -f $file > output3.txt grep -v 'foobar' "$5" | grep -f $file > output4.txt I tried many

How would I loop over pairs of values without repetition in bash?

我只是一个虾纸丫 提交于 2020-08-26 10:47:26
问题 I'm using a particular program that would require me to examine pairs of variables in a text file by specifying the pairs using indices. For example: gcta --reml-bivar 1 2 --grm test --pheno test.phen --out test Where 1 and 2 would correspond to values from the first two columns in a text file. If I had 50 columns and wanted to examine each pair without repetition (1&2, 2&3, 1&3 ... 50), what would be the best way to automate this by looping through this? So essentially the script would be

Iterate through Python dictionary and special append to new list?

扶醉桌前 提交于 2020-08-25 04:00:31
问题 I would like to iterate over a dictionary, and append each key (letter) repeated by the number of times of its value (frequency) to a new list. For example: input: {'A':1, 'B':2} . Expected output: ['A', 'B', 'B'] What I'm doing is not working. What do I write in my function to do this? def get_freq_dict(): freq_dict = {'J' : 1, 'K' : 1, 'Q' : 1, 'X' : 1, 'Z' : 1,\ 'B' : 2, 'C' : 2, 'F' : 2, 'H' : 2, 'M' : 2, 'P' : 2,\ 'V' : 2, 'W' : 2, 'Y' : 2, '' : 2,\ 'G' : 3, 'D' : 4, 'L' : 4, 'S' : 4, 'U

Iterate through Python dictionary and special append to new list?

别说谁变了你拦得住时间么 提交于 2020-08-25 03:59:46
问题 I would like to iterate over a dictionary, and append each key (letter) repeated by the number of times of its value (frequency) to a new list. For example: input: {'A':1, 'B':2} . Expected output: ['A', 'B', 'B'] What I'm doing is not working. What do I write in my function to do this? def get_freq_dict(): freq_dict = {'J' : 1, 'K' : 1, 'Q' : 1, 'X' : 1, 'Z' : 1,\ 'B' : 2, 'C' : 2, 'F' : 2, 'H' : 2, 'M' : 2, 'P' : 2,\ 'V' : 2, 'W' : 2, 'Y' : 2, '' : 2,\ 'G' : 3, 'D' : 4, 'L' : 4, 'S' : 4, 'U

How to repeat a process N times?

佐手、 提交于 2020-08-24 03:43:21
问题 I have: x = rnorm(100) # Partie b z = rbinom(100,1,0.60) # Partie c y = 1.4 + 0.7*x - 0.5*z # Partie d x1 = abs(x) y1 = abs(y) Don<-cbind(y1,x1,z) Don1 <- data.frame(Don) Reg <- glm(y1~x1+z,family=poisson(link="log"),Don1) # Partie e #Biais de beta Reg.cf <- coef(Reg) biais0 = Reg.cf[1] - 1.4 biais1 = Reg.cf[2] - 0.7 biais2 = Reg.cf[3] + 0.5 And I need to repeat all this 100 times in order to have different coefficient and calculate the bias and then put the mean of each biais in a text file.

How to repeat a process N times?

北城以北 提交于 2020-08-24 03:43:05
问题 I have: x = rnorm(100) # Partie b z = rbinom(100,1,0.60) # Partie c y = 1.4 + 0.7*x - 0.5*z # Partie d x1 = abs(x) y1 = abs(y) Don<-cbind(y1,x1,z) Don1 <- data.frame(Don) Reg <- glm(y1~x1+z,family=poisson(link="log"),Don1) # Partie e #Biais de beta Reg.cf <- coef(Reg) biais0 = Reg.cf[1] - 1.4 biais1 = Reg.cf[2] - 0.7 biais2 = Reg.cf[3] + 0.5 And I need to repeat all this 100 times in order to have different coefficient and calculate the bias and then put the mean of each biais in a text file.