Home > awk, Technical > Trim leading and trailing spaces using awk

Trim leading and trailing spaces using awk

June 18, 2010

Ans:
s=” This is a text with leading and training space ”
gsub(“^[[:space:]]*”, “”,s);
gsub(“[[:space:]]*$”, “”,s);

Ouput:This is a text with leading and training space

Advertisements
Categories: awk, Technical
%d bloggers like this: