【发布时间】:2014-05-09 01:51:43
【问题描述】:
我从从 accuweather 获取天气信息的脚本中提取了以下内容:
wget -O ./weather_raw $address
if [[ -s ./weather_raw ]]; then
egrep 'Currently|Forecast<\/title>|_31x31.gif' ./weather_raw > ./weather
sed -i '/AccuWeather\|Currently in/d' ./weather
sed -i -e 's/^[ \t]*//g' -e 's/<title>\|<\/title>\|<description>\|<\/description>//g' ./weather
sed -i -e 's/<img src="/\n/g' ./weather
sed -i '/^$/d' ./weather
sed -i -e 's/_31x31.*$//g' -e 's/^.*\/icons\///g' ./weather
sed -i -e '1s/.$//' -e '3s/.$//' -e '6s/.$//' ./weather
for (( i=2; i<=8; i+=3 ))
do
im=$(sed -n ${i}p ./weather)
sed -i $i"s/^.*$/$(test_image $im)/" ./weather
done
fi
触发上述代码的命令位于 conkyrc 文件及其~/.conkyblue/accu_weather/rss/acc_rss 中。当我从提示符运行 conkyrc 脚本时,出现错误
sed: can't read /home/me/weather: No such file or directory
确实,当我检查时,没有创建“天气”文件。但是,如果直接从提示符运行命令 ~/.conkyblue/accu_weather/rss/acc_rss,它会按预期工作并创建内容并将其放入 /home/me/weather 文件中。
我对 sed 命令一无所知,尽管由于这个麻烦,我正在尝试学习它。
代码可能有什么问题。我不认为这是一个权限问题,因为它写入的文件夹是我的主文件夹,我当然拥有它。
谢谢
【问题讨论】: