Hi!
I have this file :
------------------
24123 9 0
43411 8 1
23433 7 0
23234 3 3
I'd like my AWK script to parse it and if a zero is found on the third column, to replace it by a blank character.
Actually my script look like this :
-----------------------------------
#!/usr/bin/awk -f
{
if ($3 == 0) {
$3=""
print
}
else {
print
}
}
When I run this script over my file, it returns :
-------------------------------------------------
24123 9
43411 8 1
23433 7
23234 3 3
It works, but when printing the modified lines, it doesn't space up the columns correctly. Is there any way to have the results lined up like the original file? I'd like them to be lined up exactly like the original file, even if the columns are not spaced up equally (i.e : two spaces between the first and second column, then four space between the second and third column..)
How can I do that?
Thanks,
Zteev
I have this file :
------------------
24123 9 0
43411 8 1
23433 7 0
23234 3 3
I'd like my AWK script to parse it and if a zero is found on the third column, to replace it by a blank character.
Actually my script look like this :
-----------------------------------
#!/usr/bin/awk -f
{
if ($3 == 0) {
$3=""
}
else {
}
}
When I run this script over my file, it returns :
-------------------------------------------------
24123 9
43411 8 1
23433 7
23234 3 3
It works, but when printing the modified lines, it doesn't space up the columns correctly. Is there any way to have the results lined up like the original file? I'd like them to be lined up exactly like the original file, even if the columns are not spaced up equally (i.e : two spaces between the first and second column, then four space between the second and third column..)
How can I do that?
Thanks,
Zteev