【问题标题】:sed: can't read /home/me/weather: No such file or directorysed:无法读取 /home/me/weather:没有这样的文件或目录
【发布时间】: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/&lt;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 命令一无所知,尽管由于这个麻烦,我正在尝试学习它。

代码可能有什么问题。我不认为这是一个权限问题,因为它写入的文件夹是我的主文件夹,我当然拥有它。

谢谢

【问题讨论】:

    标签: sed conky


    【解决方案1】:

    它应该是由 egrep 创建的。

    当你运行你的脚本时,weather目录将被创建在脚本进程的pwd中。

    检查 egrep 为什么不创建文件,或者它是在哪个目录中创建的。

    【讨论】:

    • 感谢 alinsoar,但我已经检查过,但仍然无法弄清楚它为什么不创建文件。如果有帮助,我正在使用 fedora 18
    • 尝试查找带有find / -name weather的文件,可能你不知道脚本的工作目录。如果您知道工作目录,请检查它是否为脚本用户设置了+x [writing access] 标志。
    猜你喜欢
    • 2014-05-08
    • 2017-08-27
    • 2022-01-08
    • 2014-08-24
    • 2021-11-24
    • 2016-11-12
    • 2021-09-10
    • 1970-01-01
    • 2018-08-14
    相关资源
    最近更新 更多