Strip leading/trailing whitespace

Trim leading and trailing whitespace from each line

sed 's/^[[:space:]]*//;s/[[:space:]]*$//' file.txt

tool
sed15 commands
tags
sedlinux

More sed commands

all 15 sed commands