There's no escape sequence for single quotes inside single quotes. You can't write \'
like you might expect. So there are two options.
You can break out of single quotes, add an escaped single quote
\'
, and then go back in, like so:alias test='lsof -i tcp:80 | awk '\''$1 == "Google" {print $2}'\'
You can use double quotes. You then have to escape not just the double quotes inside the string but also the dollar signs.
alias test="lsof -i tcp:80 | awk '\$1 == \"Google\" {print \$2}'"