简体   繁体   中英

I need a bash script which needs to download a tar file from a website, this site has multiple files which needs to be filtered

I have a situation where I need to use curl/wget to download a tar file from a website, based on users input. If they mention a build I need to download a tar file based on the release version, I have a logic already to switch between builds, Questions is how can i filter out a particular tar file from multiple files.

curl -s https://somewebsite/somerepo-folder/os-based.tar | grep os-based* > sample.txt
curl -s https://somewebsite/somerepo-folder/os-based2.tar
curl -s https://somewebsite/somerepo-folder/os-based2.tar 

first curl downloads all files. Regex helps here, how can I place this along with curl?

if there is a mapping between the user-input and the tar file that you can think of, you can do something like this:

userInput=1
# some logic to map user-input with the tar filename to download
$tarFileName="os-based$userInput.tar"

wget "https://somewebsite/somerepo-folder/$tarFileName"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM