Trim leading and trailing spaces

Remove spaces at the start and end of each line

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

tool
sed15 commands
tags
sedlinux

More sed commands

all 15 sed commands