Если вы хотите отобразить файл с помощью Jinja, вам нужно вызвать render_template
на нем и передать ему нужные значения. Очевидно, что это не связано с прямой ссылкой на статический файл. Одним из решений является использование блока include
Jinja. Это требует, чтобы «myjs.js» находился в папке «templates / js» и будет включать его в визуализированный шаблон, передавая весь контекст шаблонов включенному шаблону.
Лучшее решение не требует рендеринга js для каждого запроса и вместо этого передает параметры js-функциям из вашего шаблона.
Этот простой awk
должен помочь вам здесь.
awk 'FNR==NR{a[$2]=(a[$2]>$1?a[$2]:$1);next} a[$2]==$1' Input_file Input_file
Объяснение:
awk '
FNR==NR{ ##Checking condition here FNR==NR which will be TRUE when first time Input_file is being read.
a[$2]=(a[$2]>$1?a[$2]:$1) ##Creating an array named a whose index is $2 and value is depending upon condition if its value is greater than $1 then leave it as it is else replace its value with current $1 value.
next ##next is awk out of box keyword which will skip all further statements.
}
a[$2]==$1 ##This statement will be executed when 2nd time Input_file is being read and checking condition if value of a[$2] is equal to first field of current line, if yes then print that line.
' Input_file Input_file ##Mentioning Input_file name 2 times here.
Это должно сделать это:
for gene in $(awk '{print $2}' myfile.txt | uniq); do
grep "$(awk -v gene=$gene '$2 == gene {print $0}' myfile.txt | head -1)" myfile.txt
done