4
使用SED我有一個問題想創造一個sitemap.xml的SED比賽日期
# Contents of filename:
# http://www.example.com/2008/10/article3.html
# http://www.example.com/2009/11/article7.html
#!/bin/bash
hostName="www.example.com"
hostTLD="$(echo ${hostName}|cut -d . -f 3)" # results in "com"
sed -i '/\.'"${hostTLD}"'\/\([0-9]{4}\)\/\([0-9]{2}\)/d' filename
之前匹配和刪除一個txt文件博客條目我無法弄清楚如何搭配年/月份。我想刪除包含所有行「.TLD /年/月/」
我知道$ hostTLD一部分工作,因爲我使用它使用不同的匹配:
sed -i '/\.'"${hostTLD}"'\/category\//d' filename # works! ".TLD/category/"
這完美地工作。謝謝! – Dan