how can I remove trailing space in the name variable in the following script:
cat flinf|$search1|$search2| awk '
{
ref_cmd=substr($0,34,20)
if ($0~/\.txt/) {
name=substr($0,4,12)
file_no=substr($0,1,3)
volume=substr($0,17,3)
site=substr($0,4,3)
print "Reformatting file: "file_no" "name":backup "name":"vol
system("reformat "name":backup "name":"volume" " ref_cmd )
}
}'
The name variable is taken from a 12 character subtring in the list, but may contain fewer thatn 12 characters. Outside of awk it is easy. There has to be a way inside awk given the current format of the command. Any ideas?
cat flinf|$search1|$search2| awk '
{
ref_cmd=substr($0,34,20)
if ($0~/\.txt/) {
name=substr($0,4,12)
file_no=substr($0,1,3)
volume=substr($0,17,3)
site=substr($0,4,3)
print "Reformatting file: "file_no" "name":backup "name":"vol
system("reformat "name":backup "name":"volume" " ref_cmd )
}
}'
The name variable is taken from a 12 character subtring in the list, but may contain fewer thatn 12 characters. Outside of awk it is easy. There has to be a way inside awk given the current format of the command. Any ideas?