Question: (Closed) awk command in shell script
1
mittu1602 • 150 wrote:
I have an awk command which runs well on terminal: this awk command creates diffrent file according to their column header. awk command:
for((i=2;i<5;i++)); do awk -v i=$i 'BEGIN{OFS=FS="\t"}NR==1{n=$i}{print $1,$i > n".txt"}' ${Batch}.result.txt; done
the same command when incorporated in a shell script shows error:
Syntax error: Bad for loop variable
ADD COMMENT
• link
•
modified 15 months ago
by
Pierre Lindenbaum ♦ 116k
•
written
15 months ago by
mittu1602 • 150
Are you sure that you are executing your script with bash and not sh or dash? The latter don't like some of the bash syntax.
please post output from
echo $SHELL
Since you're using my answer from your other thread, could you please go mark it as the accepted answer?
Hi, I have already accepted the answer. Thank you 😊
Hello mittu1602!
We believe that this post does not fit the main topic of this site.
sorry, I should have flagged this before instead of answering ; this post is not related to bioinformatics; It's just related to linux
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!