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

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -