Hello all,
Need some input from how others would solve the following issue:
I needed to download a file using wget, however the url was something like:
Code:
https://content.web.webserve.com/web/public/NULL/package-name/anotherdir/x86_64/tomcat5-webapps-5.5.23-0jpp.14.el5.x86_64.rpm?__gda__=128942323423423423406_8d5a0asdfasdfasdf678cef05e0&ext=.rpm
and the file was being saved as such. Did some reading and figured out you can use the -O to save output to custom format. However I did not want to manually input each file name so I came up with the following non-intelligent shell script:
Code:
#!/bin/bash
URL_IN=$1
OUTPUTFILE_NAME=`echo "$URL_IN" | awk -F? '{ print $1 }' | awk -F/ '{ print $NF }'`
wget -O $OUTPUTFILE_NAME $URL_IN
exit
It works but in my opinion the awk code is non-efficient and could have probably be done in one pipe or even more efficiently. My goal here was to strip off tomcat5-webapps-5.5.23-0jpp.14.el5.x86_64.rpm. Can someone chime in and give some pointers on a better way to do this?
Thanks