grep这个字符串的第一行并将其保存在一个变量中以进行wget它?

时间:2016-03-23 15:18:52

标签: bash shell awk sed

例如,我从网址

中抓取这些行
wget -qO- http://superman.com/installer/ | grep "something" 

    href="Superman-Linux-20.0.1222.x64.sh"
    href="Superman-Linux-10.0.1222.x64.sh/*fingerprint*/"
    href="Superman-Linux-10.0.1222.x64.sh/*view*/"

我只想grep

Superman-Linux-20.0.1222.x64.sh

然后我需要忘记那个

wget http://superman.com/installer/Superman-Linux-20.0.1222.x64.sh

1 个答案:

答案 0 :(得分:2)

而不是像这样的grep:egrep -o "Superman-Linux.*\.sh"

一行代表:

wget http://superman.com/installer/$(wget -qO- http://superman.com/installer/ | egrep -o "Superman-Linux.*\.sh")