Last active
November 1, 2015 06:18
-
-
Save genta/e25fc2cfffa1c619d80f to your computer and use it in GitHub Desktop.
11桁の数値を与えると、マイナンバーのチェックデジットを付与した12桁の数値を出力するシェル関数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 引数に11桁の数値を与えると、マイナンバーのチェックデジットを付与した | |
| # 12桁の数値を出力する | |
| function mynum { | |
| n=`printf %011d $1` | |
| cd=`echo -n $n|grep -o .|paste -d\* - <(echo -n '65432765432'|grep -o .)|paste -d+ - - - - - - - - - - -|sed -e 's/^/echo $(((11-(/' -e 's/$/)%11)%10))/'|sh` | |
| echo $n$cd | |
| } | |
| # 使い方: | |
| # i=10000000000; while [ $i -le 99999999999 ]; do mynum $i; i=$(($i + 1)); done | xargs -n 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment