This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Escape dots in domain name or IP address | |
# Exit if no args | |
if [ $# -eq 0 ]; then | |
echo "Usage: $0 [domain or IP]" | |
exit 1 | |
fi | |
# Add brackets into domain name or IP | |
for i in $@ | |
do | |
# Uncomment to escape every dots | |
##echo "$i" | sed -e 's/\./[.]/g' | |
# Uncomment to escape only first dot | |
##echo "$i" | sed -e 's/\./[.]/' | |
# Uncomment to escape only last dot | |
echo "$i" | rev | sed -e 's/\./].[/' | rev | |
done |
ドメイン名やIPのドットをエスケープするスクリプトです。ドットをブラケット[ ] で囲むことによってエスケープします。
すべてのドットをエスケープするパターン、最初のドットをエスケープするパターン、最後のドットをエスケープするパターンの3通りに対応してます。(対応するパターンのコメントを外して使用します)
以上