Stupid Bash Scripts – Download and unzip a file to multiple directories.
- June 24th, 2009
- By nukeit
- Write comment
I wrote this little script because some plugins I use on all my blogs get updated every day yet don’t have a public source control. Shame on those devs…
To Use
Create a file called dirfile.txt in the same directory you save the script.
Add the full paths to each of your target directories and save.
Run the script and paste in the url to the zip you want to download and extract. That’s it ![]()
#!/bin/bash # | _) | | | # \ | | | / -_) | _| _` | _ \ _| _ \ _| _` | # _| _| \_,_| _\_\ \___| _| \__| \__,_| \___/ \__| \___/ _| \__, | # ____/ #Set your wp-content/plugins list here. Contents Ex: /full/pathto/wp-content/plugins/ (one per line) DIRFILE="../dirfile.txt" function mkcd() { [ -n "$1" ] && mkdir -p "$@" && cd "$1"; } echo -n "Paste or type the url to the file download: " read -e DOWNLOAD mkcd $RANDOM-$RANDOM-$RANDOM && wget -m -nd $DOWNLOAD for dirs in $(cat $DIRFILE); do unzip -o *.zip -d ${dirs}; done