I have a gawk code like this.
#!/usr/bin/gawk -f
1 {
for (i=0;i<5;i++){
print $0
print $0, i > "/dev/stderr"
}
}
I want to redirect to a file tmp, first the stdout and then the stderr. I tried this:
gawk -f Documents/gawk_script.awk ./file &> tmp
But this call append to the file first stderr. I don't want to divide them into two files, so I'm asking if there's a way to do that.
In ./file there's such a line:
hello
hello
howareyou
well
well
while in tmp file
hello
hello
hello
hello
hello
hello
hello
hello
hello
hello
howareyou
howareyou
howareyou
howareyou
howareyou
well
well
well
well
well
well
well
well
well
well
well
hello 0
hello 1
hello 2
hello 3
hello 4
hello 0
hello 1
hello 2
hello 3
hello 4
howareyou 0
howareyou 1
howareyou 2
howareyou 3
howareyou 4
well 0
well 1
well 2
well 3
well 4
well 0
well 1
well 2
well 3
well 4