0

Simple question:

Fetch numbers(i) from a list of number; then use each of the number to do sth.

for i in list_of_number;do cat file|head -$(($i+1))|tail -1;done

This seems right but actually doesn't work. What's the problem here? thx

1 Answer 1

1

Doing this will treat list_of_number as a string; I assume this is a file which contains a list of numbers that you want to loop over.

Try instead:

for i in `cat list_of_number`;do cat file|head -$(($i+1))|tail -1;done
Sign up to request clarification or add additional context in comments.

1 Comment

no worries, I make these types of mistakes all the time. Bash can be pretty unforgiving.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.