Skip to content

Instantly share code, notes, and snippets.

@pyar6329
Created April 17, 2018 07:55
Show Gist options
  • Save pyar6329/2e4f0afb537ebc1e9a545acd34e683bb to your computer and use it in GitHub Desktop.
Save pyar6329/2e4f0afb537ebc1e9a545acd34e683bb to your computer and use it in GitHub Desktop.
download Japan Self-Defense Forces daily report
#!/bin/bash
# 要 gnu-grep, pget
set -eu
case "$(uname -s)" in
"Darwin")
cpu_cores=$(system_profiler SPHardwareDataType | grep "Total Number of Cores:" | awk '{print $NF}')
;;
"Linux")
cpu_cores=$(cat /proc/cpuinfo | grep "cpu cores" | wc -l)
;;
esac
download_lists=$(curl -s https://www.asahi.com/articles/ASL4J669JL4JUEHF016.html | ggrep -Po '(?<=href\=").+\.pdf' | sort | uniq)
multi_process=10
echo $download_lists | xargs -P $multi_process -n 1 pget -p $cpu_cores
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment