我试着运行以下命令
WGET
命令及其参数来自脚本文件(sh),但它不会运行。但是,如果我在终端或控制台上运行相同的命令,它将按预期运行。有人能告诉我我做错了什么。
GigMyurLS.SH
URL="http://craigslist.com"
wget -q ${URL} -O - | tr "\t\r\n'" ' "' | grep -i -o '<a[^>]\+href[ ]*=[ \t]*"\(ht\|f\)tps\?:[^"]\+"' | sed -e 's/^.*"\([^"]\+\)".*$/\1/g' > myurls.txt
编辑:
如果我在终端中直接运行下面的命令,它就可以工作,输出显示在代码下面。
wget -q http://craigslist.com -O - | tr "\t\r\n'" ' "' | grep -i -o '<a[^>]\+href[ ]*=[ \t]*"\(ht\|f\)tps\?:[^"]\+"' | sed -e 's/^.*"\([^"]\+\)".*$/\1/g' > myurls.txt
输出:
baby-jesus@babyjesus-X501A1:~$ wget -q http://craigslist.com -O - | tr "\t\r\n'" ' "' | grep -i -o '<a[^>]\+href[ ]*=[ \t]*"\(ht\|f\)tps\?: [^"]\+"' | sed -e 's/^.*"\([^"]\+\)".*$/\1/g'
https://post.craigslist.org/c/pit
https://accounts.craigslist.org/login/home
https://www.craigslist.org/about/sites
https://post.craigslist.org/c/pit
https://accounts.craigslist.org/login/home
https://www.craigslist.org/about/help/
https://www.craigslist.org/about/scams
https://www.craigslist.org/about/safety
https://www.craigslist.org/about/privacy.policy
https://www.craigslist.org/about/help/system-status
https://www.craigslist.org/about/
https://www.craigslist.org/about/craigslist_is_hiring
https://www.craigslist.org/about/open_source
http://blog.craigslist.org/
https://www.craigslist.org/about/best/all/
https://www.youtube.com/user/craigslist
http://www.craigslistjoe.com/
http://craigconnects.org/
https://forums.craigslist.org/?areaID=33
https://forums.craigslist.org/?areaID=33&forumID=5178
https://forums.craigslist.org/?areaID=33&forumID=3232
我只想做完全相同的事情,但从脚本文件,并通过在字符串末尾添加命令将输出指向文本文件
>MyurLS.TXT