Slugify String

Convert a string to a URL-friendly slug.

Code

General
echo "$str" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/-\+/-/g' | sed 's/^-\|-$//g'

Parameters

The string to slugify

Server

More Bash Snippets