We are processing a file using the gsub function to do a substitution of a column, removing special characters and replacing them with a null ("" value. I need to modify this script to also replace a space found in the 2nd column with the null value.
The problem: if the column contains all spaces, I want to leave it as is. The change should only be applied to the column if the data is not completely spaces but contains other values i.e. INT C should be changed to INTC.
I hoped to use the existing awk command and add the check for space and replace the values with null; write that file to a temp file and feed it into another gsub command that checks for nulls in the 2nd column and make it spaces. I have not worked with awk much and am not sure if this can be done. Do I have to create a file from the first iteration and then feed it into a separate awk program or can it be done in one step?
Below is the command currently using:
gsub(/[\/\*\.]/, "", $2); print $0
If I add: gsub(/[\/\*\.\ ]/, "", $2) ====> can I print to a file and then feed the file into another gsub command?
Any help is appreciated.
The problem: if the column contains all spaces, I want to leave it as is. The change should only be applied to the column if the data is not completely spaces but contains other values i.e. INT C should be changed to INTC.
I hoped to use the existing awk command and add the check for space and replace the values with null; write that file to a temp file and feed it into another gsub command that checks for nulls in the 2nd column and make it spaces. I have not worked with awk much and am not sure if this can be done. Do I have to create a file from the first iteration and then feed it into a separate awk program or can it be done in one step?
Below is the command currently using:
gsub(/[\/\*\.]/, "", $2); print $0
If I add: gsub(/[\/\*\.\ ]/, "", $2) ====> can I print to a file and then feed the file into another gsub command?
Any help is appreciated.