I am new to awk or nawk and inherited a script (add1.awk) , which is as follows:
#!/bin/nawk -f
{
gsub(/\015/, "")
gsub(/^ *$/, "")
gsub(/\012/, "")
gsub(/\010/, "")
}
I am issuing this command at the prompt:
add1.awk file.txt
file.txt is as follows (as you can clearly see it has bunch of blank lines in it):
Jane Doe
123 Main Street
Anywhere, SE 12345-7890
John Smith
456 amit-lined Avenue
Smallville, MW 11111-0000
Can someone explain to me what these two gsub are for i.e.
gsub(/\015/, "")
gsub(/^ *$/, "")
gsub(/\012/, "")
gsub(/\010/, "")
It seems that they are not doing anything even when I redirect it to output.txt file:
add1.awk file.txt > output.txt
output.txt is same as file.txt so first two function are not doing anything to input file and I have no idea what 3 & 4 are for?
Thanks,
Al
#!/bin/nawk -f
{
gsub(/\015/, "")
gsub(/^ *$/, "")
gsub(/\012/, "")
gsub(/\010/, "")
}
I am issuing this command at the prompt:
add1.awk file.txt
file.txt is as follows (as you can clearly see it has bunch of blank lines in it):
Jane Doe
123 Main Street
Anywhere, SE 12345-7890
John Smith
456 amit-lined Avenue
Smallville, MW 11111-0000
Can someone explain to me what these two gsub are for i.e.
gsub(/\015/, "")
gsub(/^ *$/, "")
gsub(/\012/, "")
gsub(/\010/, "")
It seems that they are not doing anything even when I redirect it to output.txt file:
add1.awk file.txt > output.txt
output.txt is same as file.txt so first two function are not doing anything to input file and I have no idea what 3 & 4 are for?
Thanks,
Al