bash - Grep 该字符串的第一行并将其保存在变量中以 wget 吗?

标签 bash shell awk sed

例如,我从 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/

相关文章:

linux - 我如何在我的 Linux 服务中为 Asterisk 设置环境变量,即使它没有真正的用户?

bash - Ansible:如何使用 Ansible chmod +x 文件?

linux - 通过正则表达式重命名文件夹中的所有文件

linux - 如何监视文件并在终端中打印出更改(使用 inotify)?

linux - 想要使用 shell 脚本在两个文件中追加记录

php - 在 linux bash 中运行 php 脚本(php 函数)

linux - 在 Linux 上获取进程 ID 的 Shell 脚本

安卓 2.3 : Read-Only file system stuck

perl - 如何通过跳行合并文件

linux - 查找两个文件的列中具有相同值的行