I have a variable that is created in bash, and want to use it within awk statement to create a file by concatenating it with a string for the filename.
awk -v value="${index}" 'BEGIN{}{print $9 >> "example_value.txt";}END{}'
How can I do this?
I have a variable that is created in bash, and want to use it within awk statement to create a file by concatenating it with a string for the filename.
awk -v value="${index}" 'BEGIN{}{print $9 >> "example_value.txt";}END{}'
How can I do this?
You have to use it outside of the double quotes. awk concatenates it without any other character:
awk -v value="${index}" 'BEGIN{}{print $9 >> "example_" value ".txt";}END{}'