Hello,
I have the following simple code (see below), which makes from this input file,where [\tab] means that there is tab instead of space:
1 1 0 1 0 0 [\tab] 1 1 0 1 0 0
this output
dd
cd
cc
dd
cd
cc
Now, this is good, but i would like to get rather output like this
dd [\tab] dd
cd [\tab] cd
cc [\tab] cc
How can i get this? Any idea?
The code:
awk '
BEGIN{
str[0] = "c";
str[1] = "d";
n = 2;
}
{
for(i=0;i<=NF;i++)
{
printf("%s",str[$i]);
if (i%n+1 == 1)
print "";
}
}'
You can run by this command:
echo 1 1 0 1 0 0 1 1 0 1 0 0 | ./program.awk
I have the following simple code (see below), which makes from this input file,where [\tab] means that there is tab instead of space:
1 1 0 1 0 0 [\tab] 1 1 0 1 0 0
this output
dd
cd
cc
dd
cd
cc
Now, this is good, but i would like to get rather output like this
dd [\tab] dd
cd [\tab] cd
cc [\tab] cc
How can i get this? Any idea?
The code:
awk '
BEGIN{
str[0] = "c";
str[1] = "d";
n = 2;
}
{
for(i=0;i<=NF;i++)
{
printf("%s",str[$i]);
if (i%n+1 == 1)
print "";
}
}'
You can run by this command:
echo 1 1 0 1 0 0 1 1 0 1 0 0 | ./program.awk