I am splitting up a file with awk command, I want to name the file using a variable however I have not had much luck. Here is the line:
awk '/STX/ {f="$tp"++i;} {print > f}' $tp.mixed
this just creates files with $tp# as name.
I read the post "How to use shell variables in awk script" but was unable to figure out how to apply that to me question.
-v awkvar="$tp"`` to create an awk variable with the value you need and then use the variableawkvar` in the awk script.f=awkvar(++i)or similar.awk -v tp="$tp" '/STX/ {if (f) close(f); f = tp (++i)} {print > f} END{if (f) close(f)}' $tp.mixedcloseevery time you are done with a file here, you will never reach that limit.