awk - awk concatenate string variable
I would like to awk concatenate string variable in awk. How can I do that? I tried:
BEGIN{
t="."
r=";"
w=t+r
print w}But I does't work. Output:
0Or I want to add variable and result of function. Input:
t t t t
a t a ta
ata ta a aScript:
{
key="t"
print gsub(key,"")#<-it's work
b=b+gsub(key,"")#<- it's something wrong
}
END{
print b}#<-so this is 0Output:
4
2
2
0#<-the last print 1 1 Answer
No operator is needed (or used). Your example would be something like
BEGIN{
t="."
r=";"
w=t r
print w}For related discussion
- 6.2.2 String Concatenation in The GNU Awk Manual
- string concatenation in AWK on Linux Questions
- Concatenate strings in awk on StackOverflow