I need to duplicate processing of this AWK script but cannot figure out what it is doing. Can anyone please advise what the basic function of this script is?
It takes an input file, and creates an output file but I do not have access to either files to see what it is doing. It has something to do with the pipe delimiter which delimits columns in the input file.
{
if (NR == 1) {
line = $0
len = length(line)
newlen = len
while ( substr(line,newlen-1,1) == "|" )
{
newlen = newlen - 1
}
line = substr(line,1,newlen-1)
}
else {
print line
line = $0
}
}
END{
len = length(line)
newlen = len
while ( substr(line,newlen-1,1) == "|" ) {
newlen = newlen - 1
}
line = substr(line,1,newlen-1)
print line
}
it looks like it’s trimming all trailing pipe chars on the first and last lines only.