我需要从一个网站下载一些网页。
我要做的是在站点源代码中使用sed获取链接,一个接一个地传递给curl,然后将下载的文件输出到正确的目录中的正确文件上。
我会尽量说得更清楚些。
在页面源代码中有如下一行:
... href="view-source: http://www.site.org/the/file-42.php">
/the/file-42.php </a>"> </span><span> OutDir and some more things ...
我得到了我需要的东西(链接文件名-脏名),像这样:
f
我试图在Bash 4 (Red )中解析yum check-update的输出,并想跳过第一行:
“此系统未注册到Red订阅管理。您可以使用订阅管理器注册。”
我使用strace来确定FD,它似乎是2/STDERR,但是用2>/dev/null重定向它不起作用。可能是什么原因?
Strace输出:
write(2, "This system is not registered to"..., 112This system is not registered to Red Hat Subscription Management. You can use subscripti
最近,在我的工作中,我面临着一个关于和进程替换的有趣问题。
让我们从例子开始:
我有三个小剧本:
$ head *.sh
文件one.sh
#!/bin/bash
echo "one starts"
if [ -p /dev/stdin ]; then
echo "$(cat /dev/stdin) from one"
else
echo "no stdin"
fi
文件two.sh
#!/bin/bash
echo "two starts"
if [ -p /dev/stdin ]; then
echo
我读过,您可以将I/O重定向到Bash中的各种构造(例如"if“和"while")。当我尝试这一点时,我注意到在if结构的末尾使用一个“AC.26”可以阻止我在if构造中覆盖的任何变量生效;但是如果我使用">“代替,那么变量修改就生效了。
#!/bin/bash
VAR_0='Unmodified'
if true
then
VAR_0='Changed'
fi | cat
echo "VAR_0: $VAR_0"
###########
VAR_1='Unmodified'