linux - 在目录和文件名中使用正则表达式获取特定文件

标签 linux wget

最佳答案

我使用以下 shell 脚本解决了它

#!/bin/bash

[ -d Test_Wget ] && (echo "directory exists,  changing directory for child process") || (mkdir Test_Wget && echo "directory created, changing directory for child process")
cd Test_Wget

if [ ! -f index.html ];
then
    wget --no-parent -A 'dmel_r*/fasta/dmel-all-translation-r*.fasta.gz' ftp://ftp.flybase.net/releases/current/
fi

awk '/href.*dmel/' index.html > url_with_crap

grep -o '".*"' url_with_crap > url_with_quotes

part_url=$(sed -e 's/^"//' -e 's/"$//' < url_with_quotes)

url="$part_url/fasta/dmel-all-translation-r*.fasta.gz"

wget $url

gunzip dmel-all-translation-r*.fasta.gz

shopt -s extglob
rm -- !(dmel-all-translation-r*.fasta)

我确信这个解决方案对于这个问题来说太天真了。 我在等待优雅的回复

关于linux - 在目录和文件名中使用正则表达式获取特定文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50472859/

相关文章:

linux - Shell 脚本 - 日期/时间和用户列表

c - 如何在不使用 C 程序中的删除系统调用的情况下删除文件?

java - 如何检查 Linux 中的进程是否正在运行?

linux - 我如何搜索 > 进入 bash 脚本

ssl - 在 Firefox 中,curl 不验证带有 --cacert 传递的导出站点证书的证书

linux - 如何在使用 GNU Parallel 的 Bash 脚本中避免 SIGCHLD 错误

linux - 在 Redhat Linux 64 位上构建 DBD::SQlite

linux - 使用 wget 下载 shell 文件

linux - HTTP 请求 : Is there a way to do a GET within a GET in linux

bash - 使用 bash 下载图像直到 url 无效