例如,我从 url 中 grep 这些行
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
最佳答案
而不是像这样的 grep: egrep -o "Superman-Linux.*\.sh"
在一行中执行以下操作:
wget http://superman.com/installer/$(wget -qO- http://superman.com/installer/ | egrep -o "Superman-Linux.*\.sh")
关于bash - Grep 该字符串的第一行并将其保存在变量中以 wget 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36182061/