I am asking for your assistance to strip blanks/spaces before & at the end each field. ie Remove the trailing space from the $1, the same apply to the beginning & trailing spaces in $2, and the leading spaces from $3 using AWK on AIX 7.2 platform. Below is some data in the file Employee.txt
001 | George John Aden Brown | gbrown
002 | Barry Street White | bwhite
003 | Kelly Jones | kjones
004 | Jolene Davidson Smith | jsmith
My objective is to achieve the following set of data (without the leading/trailing spaces)
001|George John Aden Brown|gbrown
002|Barry Street White|bwhite
003|Kelly Jones|kjones
004|Jolene Davidson Smith|jsmith
I have tried the following without satisfaction.
awk -F"|" '{ print $1 "|" gsub(" ", "", $2) "|" $3 }' Employee.txt
awk -F"|" '{ print $1 "|" gsub(/[ \t]/,"",$2) "|" $3 }' Employee.txt
awk -F"|" '{ print $1 "|" gsub(/[[:blank:]]/, "", $2) "|" $3 }' Employee.txt
001 |8| gbrown
002 |11| bwhite
003 |17| kjones
004 |8| jsmith