shell - BASH: Iterate range of numbers in a for cicle -
I want to create an array from the list of words. Therefore, I am using this code:
in the array {$ i] = $ (cat file.txt | cut -d ',' - f3 | sort -r | uniq | tail -n $ {i}) done but it failed ... in tail -n $ {i} I have already tried tail- n $ i , tail- n $ (i) , but i < / Code> Any thoughts?
This fails because you can not use a variable > (( ...)) can use operators: for ((i = 1; i & lt; = count; i ++)); Array [$ i] = $ (cut-d ',' -f3 file.txt | sort -r | uniq | tail -n $ i) done In addition, Em> Unusual use of cat from your order .
Comments
Post a Comment