SED Trick – Add slashes to filenames if needed

This sed command will append / to the end of every line in filename.txt which doesn’t already have one.

sed -i '/\/$/!s/$/\//g' filename.txt
blog comments powered by Disqus